Call RPC methods and send events to your URL with ERPC CLI

erpc rpc call sends one JSON-RPC request from your terminal with your signed-in ERPC account, or pays per call with x402. erpc webhook POSTs RPC events to your URL.
This page describes ERPC CLI v0.1.0-rc.4, a pre-release.

Call an RPC method

Use your signed-in ERPC account to call Solana or Ethereum mainnet. The CLI selects the shared endpoint from the method, or you can select the network.
sh
erpc login
erpc rpc call getSlot
erpc --json rpc call eth_getBlockByNumber '["latest", false]' --network ethereum-mainnet
erpc rpc call eth_call --params-file params.json
printf '%s' '["finalized", false]' | erpc rpc call eth_getBlockByNumber -
erpc rpc call getHealth --endpoint-url http://127.0.0.1:8899
  • Params are a JSON array or object, a file with --params-file, or - for standard input. Without them, a call sends [].
  • Networks are solana-mainnet and ethereum-mainnet (also eth-mainnet). erpc rpc list-networks lists the networks with ERPC shared and x402 RPC.
  • Your own endpoint: --endpoint-url uses only the credentials in that URL. It must be a secure URL or loopback, without user information.

Which of the account's keys a call uses

An account can have several RPC keys. erpc rpc call and erpc webhook run try them in order, the primary one first, with one getHealth call for each key before the call of their own. The key is judged at the shared Solana RPC, whatever chain is then called.
When the RPC takes no key and could not be asked about one of them, the command goes on with the first key it could not be asked about, and its own call tells. When every key is refused, the command fails with the shared RPC takes none of the account's API keys from this machine (<n> tried): see When it fails.

Pay per call with x402

For pay-per-call access without an account, request an x402 quote. --quote prints the quote without reading a wallet or making a payment.
To pay, run the command without --quote at a terminal. The CLI shows the amount, asks for confirmation, and signs the quoted Base EURC payment with the wallet erpc wallet create configured. Keep EURC on Base in that wallet (Pay from a wallet).
sh
erpc rpc call getSlot --network solana-mainnet --x402 --quote
erpc rpc call eth_blockNumber --x402

Send events to your URL

A local webhook subscribes to the RPC WebSocket and POSTs events to your URL. Start a receiver, create the subscription, then run the ID that create returns, in a terminal or under your process supervisor.
sh
erpc webhook create --name slots --network solana-mainnet \
  --url http://127.0.0.1:8080/events --method slotSubscribe
erpc webhook create --name heads --network ethereum-mainnet \
  --url http://127.0.0.1:8080/events --method eth_subscribe --params '["newHeads"]'
erpc webhook list
erpc webhook run 1
For wallet activity on Solana, use --template solana-wallet --wallet ADDRESS in place of --method. For Ethereum contract logs, use --template evm-contract-events --address CONTRACT. The callback URL is HTTPS or loopback HTTP, and the networks are the same as erpc rpc call's.

What your receiver gets

  • Each POST contains webhook_id, network and the original JSON-RPC notification. Return HTTP 2xx to accept it.
  • Delivery starts at the current live subscription. Restarting the runner subscribes to new events.
  • A disconnect or a failed callback ends the runner with a nonzero status.
  • erpc webhook run takes --once to test a single delivery, and --endpoint-url to use your own WebSocket RPC.

Manage webhooks

CommandWhat it does
erpc webhook listLists the saved subscriptions
erpc webhook show IDShows a subscription. Callback credentials are omitted
erpc webhook enabled-countCounts the subscriptions enabled on this machine
erpc webhook pause IDDisables delivery. A runner that is running exits
erpc webhook activate IDEnables a later run
erpc webhook delete IDRemoves the definition
These inspect and change local configuration only. Pass --yes to pause, activate and delete in scripts.