Call Ethereum and EVM chains from IC canisters (Rust) via the EVM RPC canister using the evm_rpc_client crate. Covers typed API calls, raw JSON-RPC, multi-provider consensus, ERC-20 reads, and sending pre-signed transactions. Use when calling Ethereum, Arbitrum, Base, Optimism, or any EVM chain from a Rust canister. Do NOT use for generic HTTPS calls to non-EVM APIs — use https-outcalls instead.
The EVM RPC canister is an IC system canister that proxies JSON-RPC calls to Ethereum and EVM-compatible chains via HTTPS outcalls. Your canister sends a request to the EVM RPC canister, which fans it out to multiple RPC providers, compares responses for consensus, and returns the result. No API keys required for default providers. No bridges or oracles needed.
evm_rpc_client crate (provides typed client API and re-exports evm_rpc_types)| Canister | ID | Subnet |
|---|---|---|
| EVM RPC (mainnet) | 7hfb6-caaaa-aaaar-qadga-cai | 34-node fiduciary |
Candid interface: https://github.com/dfinity/evm-rpc-canister/releases/latest/download/evm_rpc.did — or use the skill to fetch it directly from the mainnet canister.
canhelp| Chain | Chain ID | Candid | Rust |
|---|---|---|---|
| Ethereum Mainnet | 1 | variant { EthMainnet } | RpcServices::EthMainnet |
| Ethereum Sepolia | 11155111 | variant { EthSepolia } | RpcServices::EthSepolia |
| Arbitrum One | 42161 | variant { ArbitrumOne } | RpcServices::ArbitrumOne |
| Base Mainnet | 8453 | variant { BaseMainnet } | RpcServices::BaseMainnet |
| Optimism Mainnet | 10 | variant { OptimismMainnet } | RpcServices::OptimismMainnet |
| Custom EVM chain | any | variant { Custom } | RpcServices::Custom |
Built-in providers (no API key needed for defaults):
| Provider | Ethereum | Sepolia | Arbitrum | Base | Optimism |
|---|---|---|---|---|---|
| Alchemy | yes | yes | yes | yes | yes |
| Ankr | yes | - | yes | yes | yes |
| BlockPi | yes | yes | yes | yes | yes |
| Cloudflare | yes | - | - | - | - |
| LlamaNodes | yes | - | yes | yes | yes |
| PublicNode | yes | yes | yes | yes | yes |
Formula:
(5_912_000 + 60_000 * nodes + 2400 * request_bytes + 800 * max_response_bytes) * nodes * rpc_count
Where nodes = 34 (fiduciary subnet), rpc_count = number of providers queried.
Practical guidance: Send 10_000_000_000 cycles (10B) as a starting budget. Unused cycles are refunded. Typical calls cost 100M-1B cycles (~$0.0001-$0.001 USD).
Use requestCost to get an exact estimate before calling.
Not sending enough cycles. Every EVM RPC call requires cycles attached. The evm_rpc_client defaults to 10B cycles per call, but if you override with .with_cycles(), sending too few causes silent failures or traps.
Using default Equality consensus. The default consensus strategy requires all providers to return identical responses. This fails for queries like eth_getBlockByNumber(Latest) where providers are often 1-2 blocks apart. Use ConsensusStrategy::Threshold { total: Some(3), min: 2 } (2-of-3 agreement) for most use cases.
Ignoring the Inconsistent result variant. Even with threshold consensus, providers can still disagree beyond the threshold. Multi-provider calls return MultiRpcResult::Consistent(result) or MultiRpcResult::Inconsistent(results). Always handle both arms or your canister traps on provider disagreement.
Using wrong chain variant. RpcServices::EthMainnet is for Ethereum L1. For Arbitrum use RpcServices::ArbitrumOne, for Base use RpcServices::BaseMainnet. Using the wrong variant queries the wrong chain.
Response size limits. Large responses (e.g., eth_getLogs with broad filters) can exceed the max response size. Use .with_response_size_estimate() on the client builder or the call fails.
Calling eth_sendRawTransaction without signing first. The EVM RPC canister does not sign transactions. You must sign the transaction yourself (using threshold ECDSA via the IC management canister) and pass the raw signed bytes.
Defining EVM RPC Candid types manually. Use the evm_rpc_client crate which provides a typed client API and re-exports all Candid types from evm_rpc_types. Manual type definitions drift from the canister's actual interface and cause IC0503 decode traps at runtime.
The evm_rpc canister definition is only needed for local development — the local replica doesn't have the EVM RPC canister pre-installed, so you deploy your own copy from the pre-built WASM. On mainnet, the DFINITY-maintained canister is already deployed at 7hfb6-caaaa-aaaar-qadga-cai — do NOT deploy your own instance. Use environments to control which canisters are deployed where: