Skip to main content
CosmJS uses JSON-RPC 2.0 for all transport-level communication and xstream-based reactive streams for event subscriptions. These are low-level building blocks that most applications interact with indirectly through higher-level clients.

JSON-RPC Protocol

All transports use the JSON-RPC 2.0 protocol, implemented in @cosmjs/json-rpc. The package provides:
  • Type definitionsJsonRpcRequest, JsonRpcSuccessResponse, JsonRpcErrorResponse
  • ParsingparseJsonRpcResponse() validates and type-guards responses
  • ID generationmakeJsonRpcId() produces incrementing numeric IDs
  • Error codes — standard JSON-RPC error codes (parseError, invalidRequest, methodNotFound, etc.)
You generally don’t interact with this package directly — the RPC clients handle serialization and parsing internally.

Reactive Streams

The @cosmjs/stream package provides utilities built on xstream for working with event streams: These are primarily used internally by the WebSocket transport and subscription system, but they’re available if you need to compose or transform event streams.