Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
CosmJS
Recommended pattern for handling all transaction failure modes in CosmJS.
import { SigningStargateClient, GasPrice, TimeoutError, BroadcastTxError, isDeliverTxSuccess, Coin, } from "@cosmjs/stargate"; async function sendTokens( client: SigningStargateClient, sender: string, recipient: string, amount: readonly Coin[], ): Promise<string> { try { const result = await client.sendTokens(sender, recipient, amount, "auto"); if (isDeliverTxSuccess(result)) { return result.transactionHash; } // Execution failed (out of gas, insufficient funds, etc.) throw new Error( `Transaction ${result.transactionHash} failed with code ${result.code}: ${result.rawLog}`, ); } catch (error) { if (error instanceof BroadcastTxError) { // CheckTx rejection — do not retry without fixing the issue throw error; } if (error instanceof TimeoutError) { // Transaction may still succeed — query later console.warn("Transaction submitted but not yet confirmed:", error.txId); throw error; } throw error; } }
Error
cause.status
cause.body
BroadcastTxError
code
codespace
log
TimeoutError
txId
DeliverTxResponse
rawLog
events
Was this page helpful?