Skip to main content
Sending a transaction on a Cosmos SDK chain is a multi-step process: you build one or more messages, estimate gas, sign the transaction, broadcast it to a node, and then wait for block inclusion. This guide walks through each step using SigningStargateClient.

Prerequisites

  • Node.js v22 or later
  • @cosmjs/stargate and @cosmjs/proto-signing installed
  • An RPC endpoint for the target chain

Set Up a Signing Client

Create a wallet and connect a signing client. This example uses a mnemonic-based wallet for simplicity — see Local Wallets and Injected Wallets for production options.
Never hard-code mnemonics in source files. Use environment variables or a secrets manager.
Setting gasPrice in the client options enables "auto" fee estimation for all transactions. Without it, you must pass an explicit StdFee to every transaction method.

Transaction Lifecycle

Every transaction follows these steps:
  1. Build messages — describe what the transaction should do
  2. Estimate gas — simulate execution to determine fees
  3. Sign — produce a cryptographic signature over the transaction bytes
  4. Broadcast — send the signed transaction to a node
  5. Confirm — wait for the transaction to be included in a block
The simplest path combines all steps in a single call:
The following pages break down each step in detail.

Convenience Methods

SigningStargateClient provides high-level methods for the most common transactions. They construct the message internally and call signAndBroadcast:
These convenience methods accept the same three fee forms — "auto", a number multiplier, or an explicit StdFee.

Next Steps

Building Messages

Construct message objects for token transfers, staking, and multi-message transactions.

Simulating Gas

Estimate gas with auto fees, manual simulation, or explicit fee objects.

Signing & Broadcasting

Sign and broadcast transactions, or separate the two steps for advanced workflows.

Waiting for Confirmation

Configure polling timeouts and handle transactions that take too long.

Error Handling

Handle CheckTx rejections, execution failures, and timeouts.

Events & Lookups

Read transaction events and look up past transactions by hash or query.