The Cosmos SDK is a Go-based modular framework for building application-specific PoS blockchains that interoperate over IBC. Each chain bundles modules (bank, staking, gov, authz, ibc, wasm) and runs CometBFT (formerly Tendermint Core) consensus. For dapp clients, `@cosmjs/stargate` and `@cosmjs/cosmwasm-stargate` are the canonical TS SDKs; Keplr / Leap inject `window.keplr` / `window.leap` for browser auth across hundreds of Cosmos chains.
- 01building app-chains (sovereign L1s) with custom modules
- 02IBC-enabled multi-chain dapps (Osmosis, Injective, Celestia, Neutron, Stride)
- 03Keplr / Leap wallet auth and CosmWasm contract calls
- 04delegated PoS staking, governance, and authz module integrations
- 05rollup-style chains using Rollkit / Saga that reuse the SDK
- pnpm add @cosmjs/stargate @cosmjs/cosmwasm-stargate @cosmjs/proto-signing @keplr-wallet/types
| Variable | Scope | Description |
|---|---|---|
| NEXT_PUBLIC_COSMOS_CHAIN_ID | Client | Chain ID, e.g. `cosmoshub-4`, `osmosis-1`, `neutron-1` — Cosmos chain IDs are strings, not integers. |
| NEXT_PUBLIC_COSMOS_RPC_URL | Client | CometBFT RPC URL (e.g. https://rpc.cosmos.network). Returns chain head, blocks, and tx broadcast endpoints. |
| NEXT_PUBLIC_COSMOS_REST_URL | Client | LCD / REST URL (e.g. https://rest.cosmos.network) — used for queries via `lcd-cosmos` clients. |
| NEXT_PUBLIC_COSMOS_BECH32_PREFIX | Client | Bech32 address prefix (`cosmos`, `osmo`, `inj`, `neutron`…) — required to derive addresses from public keys. |
Use `@cosmjs/stargate`. Connect Keplr: `await window.keplr.enable(chainId); const signer = window.keplr.getOfflineSigner(chainId); const [account] = await signer.getAccounts();`. Build a signing client: `const client = await SigningStargateClient.connectWithSigner(rpcUrl, signer);`. Send tokens: `await client.sendTokens(account.address, recipient, [{ denom: 'uatom', amount: '1000000' }], 'auto', 'memo');`. For arbitrary messages use `client.signAndBroadcast(account.address, [{ typeUrl: '/cosmos.staking.v1beta1.MsgDelegate', value: MsgDelegate.fromPartial({...}) }], 'auto')`. To suggest a custom chain to Keplr call `window.keplr.experimentalSuggestChain({ chainId, chainName, rpc, rest, bech32Config: { bech32PrefixAccAddr: 'osmo', ... }, currencies: [...], stakeCurrency, feeCurrencies })`. Read state via the LCD: `fetch(restUrl + '/cosmos/bank/v1beta1/balances/' + address)`.
- ⚑Cosmos uses a deterministic bech32 address per chain — the same key produces `cosmos1…`, `osmo1…`, `inj1…`, etc. Hardcoding `cosmos1` prefixes silently breaks on other chains; always derive from `bech32Config.bech32PrefixAccAddr`.
- ⚑Account / sequence numbers are strict per-account and per-chain — bursts of transactions must include the right `accountNumber` + `sequence`. CosmJS auto-fetches once at signing; resending with a stale sequence yields `account sequence mismatch`.
- ⚑Gas in Cosmos is `gas` (units) × `gasPrice` (fee denom). Each chain sets a minimum `gasPrice` in its app.toml — Osmosis is `0.0025uosmo`, Cosmos Hub is `0.025uatom`. Sub-minimum txs are silently dropped by validators.
- ⚑CometBFT was renamed from Tendermint Core; `@cosmjs/tendermint-rpc` was renamed to `@cosmjs/cometbft-rpc` upstream and many chains run a mix of v0.34 / v0.37 / v0.38 — the RPC client must match or you'll see `unknown method` errors on `block_results`.
- ⚑Light client / IBC packets between two app-chains need a relayer (Hermes, Go relayer) and an active client/connection/channel — there is no `bridge` contract; sending an `IBCTransfer` to a stale channel locks funds in escrow until the channel re-opens or times out.
- ⚑`x/authz` and `x/feegrant` modules let one account authorize another to send transactions / pay fees on its behalf. Misconfigured grants silently let third parties drain accounts — always set narrow `MsgGrant` allow-lists with explicit expirations.
- ⚑Module versions diverge per-chain: `cosmos-sdk` v0.50 (Eden), v0.47 (Stargate v2), v0.45 — message types (`/cosmos.staking.v1beta1.MsgDelegate`) are stable but proto fields change. Always use the chain's published proto registry.