Skip to main content
A Cosmos transaction goes through several steps before it reaches the chain:
  1. Build messages — describe what the transaction should do
  2. Determine fees — calculate how much gas to pay
  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
CosmJS handles all of this through SigningStargateClient. You provide the messages and fee; the client handles serialization, signing, and broadcasting.

signAndBroadcast

The most common method. Signs the transaction, broadcasts it, and waits for inclusion in a block:

signAndBroadcastSync

Signs and broadcasts but returns immediately with just the transaction hash, without waiting for block inclusion. Useful when you don’t need to wait:

sign

Signs without broadcasting. Returns a TxRaw protobuf object — call TxRaw.encode(txRaw).finish() to serialize it into bytes that you can broadcast later or inspect:

Convenience Methods

SigningStargateClient provides high-level methods for the most common transactions. These construct the message internally and call signAndBroadcast:

Next Steps

Building Messages

Construct messages for your transactions.

Error Handling

Handle transaction failures and retries.