Skip to main content
CosmJS queries can throw errors for various reasons. The high-level clients handle common cases gracefully, but you should be aware of the patterns for each type of failure.

Missing Accounts

getAccount returns null when the address has never received tokens. It catches rpc error: code = NotFound from the chain and converts it to null:
getSequence throws if the account does not exist — call getAccount first if the address might not be funded.

Missing Delegations

getDelegation returns null when there is no delegation between the given delegator and validator. It catches "key not found" errors:

NotFound Errors on Extensions

Extension methods do not catch errors automatically. A query for a non-existent resource (e.g., a denom that doesn’t exist) throws with a message matching rpc error: code = NotFound:

Broadcast Errors

When broadcasting fails at the CheckTx stage, a BroadcastTxError is thrown with code, codespace, and log fields. If the transaction is accepted but not included in a block within the timeout, a TimeoutError is thrown with the txId so you can check later:

Next Steps

Transaction Queries

Search and decode transactions.

Querying Overview

All available query methods and extensions.