Setup a RPC Node
On Cronos POS, every node runs the same chain-maind binary. A "full/archived node", a "validator node", and an "RPC node" are the same software with different configuration — an RPC node is simply a full node with its query servers turned on and exposed. Three API surfaces are available:
Tendermint/CometBFT RPC
26657
config.toml [rpc]
YES
Raw consensus data: block, block_results, tx, status, broadcast_tx
REST API
1317
app.toml [api]
NO
Application-level REST + Swagger
gRPC
9090
app.toml [grpc]
NO
Processed chain state, used by indexers/SDKs
Do not run a public RPC node on a validator node. A validator holds block-signing keys and is a high value target; exposing RPC widens its attack surface and competes for resources, risking missed blocks and jailing. The standard topology is: validators stay private behind sentry nodes, and a separate full node serves RPC to the outside world. The rest of this guide assumes a non-validating RPC node.
Enable API and gRPC server
Tendermint/CometBFT RPC is default enabled, and auto listens rpc.laddr in config.toml below. To expose it externally, change [rpc].laddr to 0.0.0.0 and place it behind a firewall/reverse proxy.
[rpc]
laddr = "tcp://127.0.0.1:26657"To enable REST API and gRPC on application level, kindly edit ./chain-maind/config/app.toml and update the following section:
[api]
# Enable defines if the API server should be enabled.
enable = true
# Swagger defines if swagger documentation should automatically be registered.
swagger = true
# Address defines the API server to listen on.
address = "tcp://0.0.0.0:1317"
...
[grpc]
# Enable defines if the gRPC server should be enabled.
enable = true
# Address defines the gRPC server address to bind to.
address = "0.0.0.0:9090"Access RPC server
Tendermint RPC (Local access only)
You can access Tendermint Swagger UI here: https://docs.tendermint.com/master/rpc/#/
Then switch the "servers" to "localhost" in the dropdown and you can interact with the Swagger UI.
gRPC
There are a few clients our team has used before:
BloomRPC
GUI client for GRPC services
gRPCurl
Like curl, but for gRPC
Install grpcurl (Mac)
for other OSs please refer to GitHub
Query gRPC API
The reason we have to go to the
grpc/protodirectory is that gRPC will look for proto files dependency, and they expect that to be under the path you are currently at. To avoid this limitation, we can specify the proto import path.More query examples
Sist oppdatert