CosmJS communicates with Cosmos SDK chains through
Tendermint/CometBFT RPC. The
transport layer sits between the high-level clients (StargateClient,
CosmWasmClient) and the blockchain node, handling request encoding, response
parsing, connection management, and event subscriptions.
All transports implement the same RpcClient interface from
@cosmjs/tendermint-rpc, so the upper layers are transport-agnostic.
RpcClient & RpcStreamingClient
Every transport implements at least RpcClient:
Transports that support event subscriptions additionally implement
RpcStreamingClient:
You can check at runtime with instanceOfRpcStreamingClient(client).
Automatic Transport Selection
When you call StargateClient.connect(endpoint) or connectComet(endpoint),
the transport is selected based on the URL protocol:
Manual Transport Configuration
The automatic connect() methods don’t expose transport-level options like
timeouts or batching. For full control, construct the RPC client manually and
pass it through the create() factory:
When using manual transport configuration, you need to know the CometBFT version of your target chain. Use Comet38Client for CometBFT 0.38, Comet1Client for CometBFT 1.x, or Tendermint37Client for Tendermint 0.37. If you’re not sure, use connectComet() for auto-detection — though this only accepts an endpoint string or HttpEndpoint, not a pre-built RPC client.
Package Summary