Interact with EVM blockchains from the Internet Computer.
This project is currently under active development during the beta testing phase. Please feel free to submit an issue if you would like to request a feature, report a bug, or start a conversation about the EVM RPC canister.
EVM RPC is an Internet Computer canister smart contract for communicating with Ethereum and other EVM blockchains using an on-chain API.
This canister facilitates API requests to JSON-RPC services such as CloudFlare, Alchemy, Ankr, or BlockPI using HTTPS outcalls. This enables functionality similar to traditional Ethereum dapps, including querying Ethereum smart contract states and submitting raw transactions.
Beyond the Ethereum blockchain, this canister also has partial support for Polygon, Avalanche, and other popular EVM networks. Check out ChainList.org for an extensive list of networks and RPC providers.
-
Production canisters (API keys managed by DFINITY):
- Fiduciary subnet (28 nodes):
7hfb6-caaaa-aaaar-qadga-cai
- Fiduciary subnet (28 nodes):
-
Test canisters (no API keys):
- Standard subnet (13 nodes):
a6d44-nyaaa-aaaap-abp7q-cai
- Fiduciary subnet (28 nodes):
xhcuo-6yaaa-aaaar-qacqq-cai
- Standard subnet (13 nodes):
Add the following to your dfx.json
config file (replace the ic
principal with any option from the list of available canisters above):
{
"canisters": {
"evm_rpc": {
"type": "custom",
"candid": "https://github.com/internet-computer-protocol/evm-rpc-canister/releases/latest/download/evm_rpc.did",
"wasm": "https://github.com/internet-computer-protocol/evm-rpc-canister/releases/latest/download/evm_rpc_dev.wasm.gz",
"remote": {
"id": {
"ic": "7hfb6-caaaa-aaaar-qadga-cai"
}
}
}
}
}
Run the following commands to deploy the canister in your local environment:
# Start the local replica
dfx start --background
# Locally deploy the `evm_rpc` canister
dfx deploy evm_rpc --argument '(record { nodesInSubnet = 28 })'
The EVM RPC canister also supports dfx deps pull
. Add the following to your dfx.json
file:
{
"canisters": {
"evm_rpc": {
"type": "pull",
"id": "7hfb6-caaaa-aaaar-qadga-cai",
}
}
}
Next, run the following commands:
# Start the local replica
dfx start --background
# Locally deploy the `evm_rpc` canister
dfx deps pull
dfx deps init evm_rpc --argument '(record { nodesInSubnet = 28 })'
dfx deps deploy
dfx canister call evm_rpc request '(variant {Chain=0x1},"{\"jsonrpc\":\"2.0\",\"method\":\"eth_gasPrice\",\"params\":[],\"id\":1}",1000)' --wallet $(dfx identity get-wallet --ic) --with-cycles 1000000000 --ic
# Use a custom provider
dfx canister call evm_rpc request '(variant {Custom=record {url="https://cloudflare-eth.com"}},"{\"jsonrpc\":\"2.0\",\"method\":\"eth_gasPrice\",\"params\":[],\"id\":1}",1000)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
dfx canister call evm_rpc request '(variant {Custom=record {url="https://ethereum.publicnode.com"}},"{\"jsonrpc\":\"2.0\",\"method\":\"eth_gasPrice\",\"params\":[],\"id\":1}",1000)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
# Register your own provider (requires `RegisterProvider` authorization)
dfx canister call evm_rpc registerProvider '(record { chainId=1; hostname="cloudflare-eth.com"; credentialPath="/v1/mainnet"; cyclesPerCall=0; cyclesPerMessageByte=0; })'
# Use a specific EVM chain
dfx canister call evm_rpc request '(variant {Chain=0x1},"{\"jsonrpc\":\"2.0\",\"method\":\"eth_gasPrice\",\"params\":[],\"id\":1}",1000)' --wallet $(dfx identity get-wallet) --with-cycles 1000000000
PRINCIPAL=$(dfx identity get-principal)
dfx canister call evm_rpc authorize "(principal \"$PRINCIPAL\", variant { RegisterProvider })"
dfx canister call evm_rpc getAuthorized '(variant { RegisterProvider })'
dfx canister call evm_rpc deauthorize "(principal \"$PRINCIPAL\", variant { RegisterProvider })"
Contributions are welcome! Please check out the contributor guidelines for more information.
Run the following commands to set up a local development environment:
# Clone the repository and install dependencies
git clone https://github.com/internet-computer-protocol/evm-rpc-canister
cd ic-eth-rpc
npm install
# Deploy to the local replica
dfx start --background
npm run generate
dfx deploy evm_rpc
Regenerate language bindings with the generate
npm script:
npm run generate
- Bitcoin canister: interact with the Bitcoin blockchain from the Internet Computer.
- ckETH: a canister-issued Ether twin token on the Internet Computer.
- IC 🔗 ETH: a full-stack starter project for calling Ethereum smart contracts from an IC dapp.