Run the Ethereum JSON-RPC Adapter¶
Introduction¶
The Ethereum JSON-RPC adapter, eth-rpc, is a server that lets Ethereum wallets, libraries, and development tools work with a chain whose runtime includes pallet-revive. It accepts standard Ethereum JSON-RPC requests, translates them into Polkadot SDK RPC calls and runtime API calls to a node, and returns Ethereum-compatible responses.
The adapter is the eth-rpc binary of the pallet-revive-eth-rpc crate in the Polkadot SDK. This page shows how to build it, run it next to a local node, and configure it. For the Ethereum methods it serves, see JSON-RPC APIs.
Prerequisites¶
Before you start, make sure you have:
- Rust and the Polkadot SDK dependencies installed, if you build the adapter from source.
- A node whose runtime includes
pallet-revive. For local development, the Local Development Node guide shows how to build the Revive dev node. To addpallet-reviveto your own runtime, see Add pallet-revive to Your Runtime.
How the Adapter Works¶
eth-rpc runs as a separate process and connects to a node over WebSocket, by default at ws://127.0.0.1:9944. On startup, it reads the ChainId constant of pallet-revive from the node, which it returns for eth_chainId.
While it runs, the adapter subscribes to new best and finalized blocks and stores Ethereum receipt data in a SQLite database, which it uses to answer queries such as eth_getTransactionReceipt and eth_getLogs. Depending on the pruning mode, it also syncs historical blocks backward from the chain head.
It serves JSON-RPC over HTTP and WebSocket on port 8545 by default, so a local adapter is reachable at http://127.0.0.1:8545.
Get the Adapter¶
You can build eth-rpc from the Polkadot SDK source or use the parity/eth-rpc Docker image.
Build from Source¶
Clone the Polkadot SDK at the release you want and build the eth-rpc binary:
git clone --branch polkadot-stable2609-1 --depth 1 https://github.com/paritytech/polkadot-sdk.git
cd polkadot-sdk
cargo build -p pallet-revive-eth-rpc --bin eth-rpc --release
The binary is written to target/release/eth-rpc. Check that it runs:
Note
The adapter's client is generated at build time from the metadata of the Revive dev runtime in the same source tree. Building the adapter from the same Polkadot SDK release as the runtime you connect it to keeps the two in step.
Use the Docker Image¶
The parity/eth-rpc image contains the eth-rpc binary as its entry point. Tags follow the Polkadot SDK release naming, such as stable2609-1. Without arguments, the container prints the help text. The image exposes port 8545 for JSON-RPC and port 9616 for Prometheus metrics.
The image is built from the eth-rpc Dockerfile in the Polkadot SDK repository.
Run the Adapter Against a Local Node¶
-
Start a local node with
pallet-revivein its runtime. For example, from thepolkadot-sdkdirectory, build and start the Revive dev node: -
In a second terminal, start the adapter in development mode:
The adapter connects to the node at
ws://127.0.0.1:9944and serves JSON-RPC athttp://127.0.0.1:8545. -
In a third terminal, check that the adapter responds by requesting the chain ID:
curl -s -X POST http://127.0.0.1:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'The result is the
ChainIdthat the node's runtime configures forpallet-revive, in hexadecimal.
The --dev flag changes the adapter's behavior in the following ways:
- Temporary storage: Without
--base-path, the database is created in a temporary directory that is deleted on exit. The adapter logs a warning about this when it runs in archive mode. Pass--base-pathto keep the database between runs. - CORS: All origins are allowed, unless you set
--rpc-cors. - Development accounts:
eth_accountsreturns five development accounts (Alith, Baltathar, Charleth, Dorothy, and Ethan). Outside development mode, the adapter manages no accounts.
To see more detail, raise the log level for the eth-rpc target:
To connect to a node on another address, pass its WebSocket URL:
Configure Storage and Pruning¶
The --eth-pruning flag selects how the adapter stores receipt data:
archive(default): Stores data in a persistent on-disk database and syncs all historical blocks. This mode requires the node to be an archive node.<N>: Keeps only the latestNblocks in an in-memory database.Nmust be at least1. The adapter does not sync historical blocks in this mode.
In archive mode, the adapter creates an eth-rpc.db SQLite database in the directory set by --base-path (short form -d). Without --base-path and outside --dev, it uses a platform default directory:
| Platform | Default Database Directory |
|---|---|
| Linux | ~/.local/share/eth-rpc/ |
| macOS | ~/Library/Application Support/eth-rpc/ |
| Windows | %APPDATA%\eth-rpc\ |
For example, to keep a local database in ./eth-rpc-data:
To keep only the latest 256 blocks in memory:
Command-Line Options¶
eth-rpc defines a few options of its own and reuses the shared RPC, logging, and Prometheus options of the Polkadot SDK node CLI. The options below come from the adapter's CLI source and the sc-cli parameter definitions. Run eth-rpc --help for the complete list.
Adapter Options¶
| Option | Description | Default |
|---|---|---|
--node-rpc-url | WebSocket URL of the node to connect to | ws://127.0.0.1:9944 |
--eth-pruning | Receipt storage mode: archive or a number of blocks to keep in memory | archive |
--allow-unprotected-txs | Accept transactions without a chain ID, which the adapter rejects by default | Disabled |
--dev | Development mode, as described in Run the Adapter Against a Local Node | Disabled |
-d, --base-path | Directory for the eth-rpc.db database | Platform default, or a temporary directory with --dev |
RPC Server Options¶
| Option | Description | Default |
|---|---|---|
--rpc-port | Port for the JSON-RPC server | 8545 |
--rpc-external | Listen on all network interfaces instead of only on localhost | Disabled |
--unsafe-rpc-external | Same as --rpc-external, without the warning | Disabled |
--rpc-cors | Comma-separated list of allowed browser origins, or all to disable origin checks | Localhost and https://polkadot.js.org; all origins with --dev |
--rpc-max-connections | Maximum number of RPC server connections | 100 |
--rpc-max-request-size | Maximum request payload size in megabytes | 15 |
--rpc-max-response-size | Maximum response payload size in megabytes | 15 |
--rpc-max-subscriptions-per-connection | Maximum concurrent subscriptions per connection | 1024 |
--rpc-message-buffer-capacity-per-connection | Number of messages the server buffers per connection | 64 |
--rpc-rate-limit | Maximum calls per minute for each connection | Disabled |
--rpc-rate-limit-whitelisted-ips | IP ranges in CIDR notation that are exempt from rate limiting | None |
--rpc-rate-limit-trust-proxy-headers | Trust X-Real-IP, X-Forwarded-For, and Forwarded headers for rate limiting | Disabled |
--rpc-disable-batch-requests | Reject batch requests | Disabled |
--rpc-max-batch-request-len | Maximum number of calls in a batch request | None |
The adapter also applies --rpc-max-request-size and --rpc-max-response-size to its own connection to the node.
Logging and Metrics Options¶
| Option | Description | Default |
|---|---|---|
-l, --log | Log filter, such as info,eth-rpc=debug | info for all targets |
--detailed-log-output | Include the log target, level, and thread name in log lines | Disabled |
--disable-log-color | Disable colored log output | Disabled |
--prometheus-port | Port for the Prometheus metrics endpoint | 9616 |
--prometheus-external | Expose the metrics endpoint on all interfaces | Disabled |
--no-prometheus | Disable the metrics endpoint | Disabled |
Removed Options¶
PR #11153 removed several storage options. The adapter exits with an error that references the PR if you pass any of them:
| Removed Option | Replacement |
|---|---|
--database-url | --base-path for an on-disk database, or --eth-pruning=<N> for an in-memory database |
--cache-size | --eth-pruning=<N> |
--index-last-n-blocks | --eth-pruning=archive |
--earliest-receipt-block | None; the adapter discovers the first EVM block |
Production Considerations¶
The adapter's source documents the following points that matter outside local development:
- Archive node: The default
archivepruning mode syncs all historical blocks and requires the node to be an archive node. Against a pruned node, consider--eth-pruning=<N>, which keeps only recent blocks. - Public exposure: By default, the adapter listens only on localhost. The
--rpc-externaloption warns that not all RPC methods are safe to expose publicly and recommends placing an RPC proxy server in front of the endpoint to filter methods. - Persistent storage: Set
--base-pathto a persistent directory so the receipt database survives restarts. - Unprotected transactions: Leave
--allow-unprotected-txsdisabled unless you need to accept transactions signed without a chain ID (EIP-155 replay protection).
For Docker and systemd setups next to a parachain RPC node, see Ethereum RPC Compatibility.
Where to Go Next¶
-
Reference JSON-RPC APIs
Browse the Ethereum JSON-RPC methods the adapter supports, with request examples.
-
Guide Add pallet-revive to Your Runtime
Add
pallet-reviveand the runtime APIs the adapter needs to your own Polkadot SDK runtime.
| Created: November 17, 2026