Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

signAndBroadcastTx

Sign a list of messages with the client signer and broadcast the resulting transaction. The end-to-end entry point for every mutation.

Signature

function signAndBroadcastTx(
  client: Client<Signer>,
  parameters: {
    sender: Address
    messages: Message[]
    gasLimit?: number
    typedData?: TypedDataParameter<TxMessageType>
  },
): Promise<{ hash: Uint8Array } & TxData>

Example

import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createSignerClient({
  chain: testnet,
  transport: createTransport(),
  signer: PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!),
})
const sender: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
const result = await client.signAndBroadcastTx({
  sender,
  messages: [
    {
      transfer: {
        "0xabcdef1234567890abcdef1234567890abcdef12": { dango: "1000000" },
      },
    },
  ],
})

Parameters

senderAddress. Account that sends and pays for the transaction.

messagesMessage[]. The list of messages to execute (transfer, execute, instantiate, etc.).

gasLimitnumber, optional. Skip simulation and use this gas limit directly. When omitted, the SDK calls simulate and applies the default 1.3× scaling.

typedDataTypedDataParameter<TxMessageType>, optional. Pre-built EIP-712 typed data structure for the messages. When omitted, the action consumer builds it (every action like transfer, execute does this).

Returns

{ hash: Uint8Array } & TxData — see broadcastTxSync.

Notes

  • The client must have a signer; throws "client must have a signer" otherwise.
  • Calls getAccountSeenNonces and getAccountInfo to derive the nonce and user index automatically.
  • Throws "account not found" if the sender has no on-chain account.

See also