Skip to main content
CometBFT RPC is a remote procedure call protocol that provides access to blockchain data, transaction broadcasting, validator information, and node status. The RPC server supports multiple transport protocols to accommodate different use cases. CometBFT supports the following RPC protocols:
  • URI over HTTP - REST-like interface for simple queries
  • JSONRPC over HTTP - Standard JSON-RPC 2.0 protocol
  • JSONRPC over WebSockets - Persistent connection with subscription support

Configuration

RPC can be configured by tuning parameters under the [rpc] section in the $CMTHOME/config/config.toml file or by using the --rpc.X command-line flags.

Default Settings

The default RPC listen address is tcp://127.0.0.1:26657. To set another address, update the laddr config parameter:

CORS Configuration

CORS (Cross-Origin Resource Sharing) can be enabled by setting the following config parameters:
  • cors_allowed_origins - List of allowed origin domains
  • cors_allowed_methods - HTTP methods allowed for CORS requests
  • cors_allowed_headers - Headers allowed in CORS requests

Protocol Examples

URI over HTTP

A REST-like interface for simple queries:

JSONRPC over HTTP

JSONRPC requests can be POST’d to the root RPC endpoint:
Response format:

JSONRPC over WebSockets

JSONRPC requests can also be made via WebSocket for real-time updates. The WebSocket endpoint is at /websocket, e.g. localhost:26657/websocket.
Asynchronous RPC functions like event subscribe and unsubscribe are only available via WebSockets.

Subscribing to Events

Using the websocat tool, you can subscribe to ‘NewBlock’ events:
You’ll receive notifications as new events occur:

Available Event Types

You can subscribe to the following event types:
  • NewBlock - Emitted when a new block is committed
  • NewBlockHeader - Emitted for new block headers
  • Tx - Emitted for transactions
  • ValidatorSetUpdates - Emitted when the validator set changes

Endpoint Categories

The CometBFT RPC API is organized into several categories:
Unsafe Methods: Methods in the “Unsafe” category can affect node operation and must be manually enabled in the configuration. They should only be used by node operators who understand the implications.

Arguments

Arguments which expect strings or byte arrays may be passed as:
  • Quoted strings: "abc"
  • 0x-prefixed hex strings: 0x616263

Common Use Cases

Querying Blockchain Data

Broadcasting Transactions

Node Status and Health

Next Steps

RPC Methods Reference

Browse the complete API reference in the sidebar - all ~30 RPC methods with interactive examples and detailed parameters

WebSocket Subscriptions

Learn more about subscribing to real-time events