The RPC server provides an API for interacting with a CometBFT node, including blockchain data, transaction broadcasting, and node information.
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
The default RPC listen address is tcp://127.0.0.1:26657. To set another address, update the laddr config parameter:
Copy
Ask AI
[rpc]# TCP or UNIX socket address for the RPC server to listen onladdr = "tcp://127.0.0.1:26657"# A list of origins a cross-domain request can be executed from# Default value '[]' disables cors support# Use '["*"]' to allow any origincors_allowed_origins = []# A list of methods the client is allowed to use with cross-domain requestscors_allowed_methods = ["HEAD", "GET", "POST"]# A list of non simple headers the client is allowed to use with cross-domain requestscors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"]
# Get block at height 5curl http://localhost:26657/block?height=5# Get node statuscurl http://localhost:26657/status# Get validators at height 1curl http://localhost:26657/validators?height=1
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.
# Get the latest blockcurl http://localhost:26657/block# Get block at specific heightcurl http://localhost:26657/block?height=100# Search for transactionscurl 'http://localhost:26657/tx_search?query="tx.height>100"&prove=false'