Prerequisites
- Node.js v22 or later
- npm, yarn, or pnpm
- A Cosmos SDK chain RPC endpoint (e.g.
https://rpc.my-chain.networkfor the Cosmos Hub)
1
Install
2
Connect to a chain
Create a read-only client and verify the connection:
3
Query balances
Use the connected client to look up any account’s balance:
4
Create a signer
To send transactions you need a signer. You can create one from a mnemonic for development, or connect a browser wallet like Keplr in production.
- From mnemonic
- Keplr wallet (browser)
5
Send tokens
Connect a signing client and broadcast a token transfer:
Setting fee to
"auto" lets CosmJS simulate the transaction and estimate gas automatically. You can also pass an explicit StdFee object for fine-grained control.6
Send arbitrary messages
For transactions beyond simple token transfers, construct message objects directly:
Next Steps
Clients
Understand read-only and signing client architecture.
Querying
Query balances, staking, governance, and custom modules.
Fees & Gas
Configure gas pricing, simulation, and fee calculation.
CosmWasm
Deploy, instantiate, and execute smart contracts.