How users interact with a chain
Every operation a user performs falls into one of two categories:- Transactions: state-changing operations broadcast to the network and included in blocks (send tokens, delegate stake, vote on a proposal)
- Queries: read-only requests that return data from the current chain state without going through consensus
Interface comparison
All endpoints default tolocalhost and must be configured to be accessible over the public internet.
| Interface | Default port | Best for | Notes |
|---|---|---|---|
| CLI | — | Development, testing, and node operations | Best for operator and developer workflows |
| gRPC | 9090 | Wallets, backend services, and SDK clients | Not supported in browsers (requires HTTP/2) |
| REST | 1317 | Web applications, scripts, and environments without gRPC support | Use when gRPC is unavailable; REST is disabled by default |
| CometBFT RPC | 26657 | Consensus and blockchain data queries | Limited to consensus-layer data |
CLI
The CLI is the primary tool for developers and operators interacting with a chain from the terminal. Most Cosmos SDK chains ship a single binary that acts as both the server process and the CLI client. It is common to append ad suffix to the binary name to indicate that it is a daemon process, such as exampled or simd.
When used as a client, the CLI constructs a transaction or query, signs it if required, and submits it through the node client interface.
To learn how to run a local node and use the CLI, see Run a Local Node.
Using the CLI
CLI commands are organized into two categories:querycommands retrieve information from chain statetxcommands construct and broadcast transactions
--fromspecifies the signing key--gas autoasks the CLI to estimate gas usage--gas-adjustmentapplies a safety multiplier to the estimate--feesspecifies the transaction fee
How modules expose CLI commands with AutoCLI
In modern Cosmos SDK applications, modules expose CLI commands through AutoCLI. AutoCLI reads a module’s protobuf service definitions and generates CLI commands automatically, without requiring modules to hand-write Cobra command boilerplate. The counter snippets in this section are from the minimal counter module example.
A module opts into AutoCLI by implementing AutoCLIOptions() on its AppModule:
AutoCLI uses this configuration to generate the exampled tx counter add and exampled query counter count commands. The Service field names the protobuf service, and RpcCommandOptions maps individual RPC methods to CLI subcommands with positional arguments, flags, and help text.
The AutoCliOpts() method on the application struct collects these options from all modules and passes them to the AutoCLI framework at startup:
AutoCLI, which wires the generated commands into the root command.
gRPC
gRPC is the primary programmatic interface for interacting with a Cosmos chain. It uses Protocol Buffers to define strongly typed request and response structures and supports generated clients for many programming languages. Each module exposes its functionality through two protobuf services:- A
Queryservice for read-only access to module state - A
Msgservice for state-changing operations
query.proto and tx.proto files. The protobuf definitions for the Cosmos SDK are published at buf.build/cosmos/cosmos-sdk.
How modules expose gRPC services
Modules register their gRPC services during application startup viaRegisterServices:
RegisterServices to connect service implementations to the application routers:
RegisterMsgServer routes incoming Msg service calls to the module’s MsgServer implementation. RegisterQueryServer routes incoming Query service calls to the module’s QueryServer implementation.
How to interact with gRPC
Connect to the node’s gRPC endpoint (default:localhost:9090) using a generated client:
app.toml:
grpc.enable = true|false— enables or disables the gRPC server (default:true)grpc.address = {string}— theip:portthe server binds to (default:localhost:9090)
REST via gRPC-gateway
The Cosmos SDK also exposes a REST API. REST endpoints are not written by hand; they are generated automatically from the same protobuf definitions used by gRPC, using gRPC-gateway. gRPC-gateway reads HTTP annotations in the.proto files and generates a reverse proxy that translates REST requests into gRPC calls:
GET /example/counter/v1/count HTTP endpoint. The gateway receives the HTTP request, marshals it into a QueryCountRequest, calls the gRPC Count handler, and returns the response as JSON.
Registering REST routes
REST routes are registered inRegisterAPIRoutes:
app.toml:
api.enable = true|false— enables or disables the REST server (default:false)api.address = {string}— theip:portthe server binds to (default:tcp://localhost:1317)
Swagger
When the REST server and Swagger are both enabled, the node exposes a Swagger (OpenAPI v2) specification athttp://localhost:1317/swagger/. Swagger lists all REST endpoints, request parameters, and response schemas, and provides a browser-based interface for exploring the REST API.
Both are disabled by default. Enable them in app.toml:
CometBFT RPC
CometBFT also exposes its own RPC server, independent of the Cosmos SDK. It serves consensus and blockchain data and is configured under therpc table in config.toml (default: tcp://localhost:26657). An OpenAPI specification of all CometBFT RPC endpoints is available in the CometBFT documentation.
Some CometBFT RPC endpoints are directly related to the Cosmos SDK:
/abci_query— queries the application for state. Thepathparameter accepts any protobuf fully-qualified service method (for example,/cosmos.bank.v1beta1.Query/AllBalances), or special paths like/app/simulateand/app/version./broadcast_tx_sync,/broadcast_tx_async,/broadcast_tx_commit— broadcast a signed transaction to peers. The CLI, gRPC, and REST interfaces all use these CometBFT RPCs under the hood.
End-to-end interaction flow
To illustrate how these interfaces connect, here is the path of acounter add transaction from the user’s terminal to a state change on the chain. This example follows the minimal counter module example’s CLI shape.
AnteHandler. They read committed state and return immediately.
Interfaces and consensus
The CLI, gRPC, and REST interfaces are transport layers. They construct, sign, and deliver messages, but they do not participate in consensus and cannot affect the determinism of block execution.- Transactions become part of consensus only after they pass
CheckTxand are included in a proposed block. The interface used to submit the transaction has no bearing on how it is validated or ordered. - Queries bypass the transaction pipeline entirely. They read committed state from a node and never reach the consensus engine.
- Any node in the network can serve queries or accept transaction submissions. The result is always the same committed state, regardless of which node or which interface is used.