Skip to main content

ICP ETH developer workflow

Advanced
Ethereum

Overview

Developers on ICP can create canisters and dapps that interact with the Ethereum mainnet, Sepolia testnet, and other EVM-compatible networks through ICP's Ethereum integration. To use this integration, developers must implement a specific workflow that makes JSON-RPC calls to the EVM RPC canister in order to query network information and submit transactions to an EVM-compatible network. Developers can also integrate and interact with chain-key Ethereum (ckETH) from within a canister, which uses the ICRC-1 token implementation.

Using the Ethereum integration

To interact with the Ethereum network or another EVM-compatible network, a developer will need to use a combination of the management canister API and EVM RPC canister RPC methods to complete the following steps:

  1. Generate a public key: To sign and submit transactions, your canister will need a public key. You will also need this public key to generate an Ethereum wallet address.

  2. Sign a transaction: Next, a transaction must be signed before it can be submitted to the Ethereum network and executed. Transactions are signed using threshold ECDSA, a novel protocol as part of ICP's chain-key signatures suite.

  3. Submit a transaction: Signed raw transactions can be submitted using the EVM RPC canister's RPC method eth_sendRawTransaction. Code examples for sending transactions can be found in the EVM RPC canister documentation.

  4. Read information from the Ethereum network: Information from the Ethereum network can be queried using RPC methods such as:

    - eth_getBlockByNumber: Returns information about a given block.

    - eth_getTransactionCount: Returns the number of transactions for a specified address.

    - eth_getTransactionReceipt: Returns details about a submitted transaction.

    - eth_feeHistory: Returns the historical fee data to estimate gas prices for transactions.

    - eth_getLogs: Returns the logs of a specified block or transaction.

Each of these steps can be executed programmatically within a smart contract that is deployed on ICP. View the EVM RPC canister documentation to see code examples for each RPC method.

Additional sample projects can be found in the EVM RPC canister documentation.

Integrating with Ethereum

The Ethereum integration can be incorporated into dapps for several purposes, such as authentication, as shown in the Sign In With Ethereum (SIWE) example. The SIWE example showcases how to use an Ethereum wallet to sign into ICP applications. It creates a 1:1 correlation between Ethereum addresses and ICP principals within the scope of the application. It also guarantees that logging in with an Ethereum wallet will consistently produce the same principal regardless of the client used.

Using ckETH

Chain-key Ethereum (ckETH) is a digital twin token of Ethereum that is backed 1:1 with Ethereum held within an ICP smart contract. ckETH tokens comply with the ICRC token standard.

ckETH and other chain-key tokens can be interacted with in the same manner as other ICRC tokens. There aren't any special workflow steps, parameters, or smart contract types that must be used to integrate with chain-key tokens such as ckETH.

Learn more about ckETH.

Using ckERC20 tokens

ckERC20 tokens, such as ckUSDC, are able to be deployed on ICP and backed 1:1 by their native currency, such as USDC for ckUSDC. Other ckERC20 tokens have been proposed, such as OCT and ckLINK.

Resources