Transactions
What this teaches: the sign → broadcast → poll loop, and where signAndBroadcastTx fits.
The lifecycle
Build messages
A transaction is a list of Message variants (transfer, execute, instantiate, etc.).
Sign
The signer produces an EIP-712 typed-data signature over the messages plus metadata (chain id, nonce, sender).
Broadcast
The signed transaction is sent via the indexer's broadcastTxSync mutation.
Poll
The SDK polls queryTx until the indexer reports the transaction landed (or fails).
signAndBroadcastTx wraps all four steps. Higher-level actions like transfer, execute, and swapExactAmountIn build their messages then call signAndBroadcastTx.
Worked example
import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
const client = createSignerClient({
chain: testnet,
transport: createTransport(),
signer: PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!),
})
const result = await client.signAndBroadcastTx({
sender: "0x1234567890abcdef1234567890abcdef12345678",
messages: [
{
transfer: {
"0xabcdef1234567890abcdef1234567890abcdef12": { dango: "1000000" },
},
},
],
})
console.log(result.hash)Behind the scenes:
- The client queries
queryStatusfor the chain id (if not on the chain config),getAccountSeenNoncesfor the next nonce, andgetAccountInfofor the user index. - It calls
simulateto estimate gas (multiplier1.3) unlessgasLimitis set. - The signer signs the EIP-712 typed data, the SDK calls
broadcastTxSync, then pollsqueryTxup to 30 times at 500ms intervals.
Gas
simulate returns gasUsed * 1.3. To override, pass gasLimit explicitly:
await client.signAndBroadcastTx({
sender,
messages: [...],
gasLimit: 500_000,
})Failure modes
- The simulated transaction fails —
simulatethrows with the contract error. - The transaction enters the mempool but fails on commit —
queryTxreturns a non-zero code; the SDK throws. - The transaction never lands — the poll loop exhausts retries; the SDK throws "Transaction not found".
See Error Handling for narrowing these.
Next
- Subscriptions — listen for events instead of polling