Registry / blockchain / cosmos-client

cosmos-client

JSON →
library0.42.14jsnpmunverified

JavaScript/TypeScript REST API client for Cosmos SDK blockchain. Current stable version is 0.42.14, with the first two version digits matching the targeted Cosmos SDK release (0.42.x). Release cadence follows Cosmos SDK releases for minor versions, with independent patch updates. Key differentiators: provides full TypeScript types, generates protobuf definitions on-the-fly, supports account generation from mnemonics, transaction building and signing, and broadcasting. It uses Long for 64-bit integers and requires a running Cosmos SDK node with REST API enabled.

npm install cosmos-client
INSTALL
IMPORT
SIG · COSMOS-CLIENT
C
cosmos-client
blockchainjavascriptv0.42.14
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cosmosclient
import { cosmosclient } from 'cosmos-client'
import cosmosclient from 'cosmos-client'
cosmosclient is a named export, not default
rest
import { rest } from 'cosmos-client'
const rest = require('cosmos-client').rest
ESM-style import recommended
proto
import { proto } from 'cosmos-client'
import proto from 'cosmos-client'
proto is a namespace containing generated protobuf classes

Creates a CosmosSDK instance, queries account info for an address, and prints it.

import { cosmosclient, rest, proto } from 'cosmos-client'; async function main() { const sdk = new cosmosclient.CosmosSDK('https://api.cosmos.network', 'cosmoshub-4'); const address = 'cosmos1qpercj9t2l5p3q3t8x4y5z6w7v8u9m0n1k2l3p'; const account = await rest.cosmos.auth .account(sdk, address) .then((res) => res.data.account && cosmosclient.codec.unpackCosmosAny(res.data.account)); console.log(account); } main().catch(console.error);
Debug
Known issues
breakingMajor version mismatches Cosmos SDK version. Version 0.42.x only works with Cosmos SDK v0.42.x.
fix
Use version that matches your target Cosmos SDK version (e.g., 0.44.x for SDK v0.44.x).
affects: 0.42.0
deprecatedREST API is deprecated in Cosmos SDK; gRPC-web is recommended.
fix
Consider using @cosmjs/stargate for gRPC-web based clients.
affects: >=0.40.0
gotchacosmosclient.Long is required for constructing proto messages with int64 fields; plain numbers may cause errors.
fix
Use cosmosclient.Long.fromString('200000') instead of 200000.
affects: >=0.40.0
gotchaProto types must be accessed via the proto namespace (e.g., proto.cosmos.bank.v1beta1.MsgSend).
fix
Ensure imports include { proto } from 'cosmos-client'.
affects: >=0.40.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'account')
Trying to access account from response without proper type checking
fix
Add optional chaining or type guard: res.data?.account && cosmosclient.codec.unpackCosmosAny(res.data.account)
Error: Expected Long, got number
Passing a JavaScript number where a Long is expected (e.g., gas_limit)
fix
Use cosmosclient.Long.fromString('200000') instead of 200000
Module '"cosmos-client"' has no exported member 'codes'
Attempting to import 'codes' which is not exported directly
fix
Import from the correct path: import { codes } from 'cosmos-client/x/...
Upgrade
Version history
0.42.14latest on npm
Audit
Dependencies
@cosmjs/proto-signingrequiredrequired for protobuf serialization
longrequiredused for 64-bit integer handling
Agent activity
30 hits · last 30 days
node
26
OpenAI (training)
1
Resources
cosmos-client — npm install cosmos-client · libregistry