Understanding ICP for Ethereum developers
This guide is designed to help Ethereum developers understand the core concepts of ICP, focusing on the terminology and functionalities that differ between the two protocols. While the underlying concepts might be similar, ICP utilizes different terms to describe them.
For a feature comparison between the two protocols, refer to the quick comparison between ICP and Ethereum.
Terminology mapping
This table summarizes the key terminology differences between Ethereum and ICP:
Ethereum term | ICP term | Notes |
---|---|---|
Smart contract | Canister | |
Gas | Cycles | |
Shard | Subnet | |
Node | Replica | |
Account | Principal | |
DAO | SNS | An SNS refers to a DAO using ICP's unique framework However, ICP DAOs can launch without using this framework. |
Message | Memo | On Ethereum, you can encode data, often referred to as a message, as a hexadecimal in the optional data field of any transaction. Some tools allow you to input text, which they then convert to hexadecimal in the background. On ICP, you can encode data as an arbitrary blob, provided it is less than 32 bytes, in the optional memo field of any ICRC1 transaction. |
In addition, ICP has implemented similar token standards as Ethereum:
Ethereum standard | ICP standard |
---|---|
ERC-20 | ICRC-1/ICRC-2 |
ERC-721 | ICRC-7 |
Smart contracts
Both Ethereum and ICP allow developers to deploy programs that run onchain. These programs are referred to as smart contracts on Ethereum and canister smart contracts, or simply just canisters, on ICP.
This comparison provides an overview of the key differences in smart contract development on Ethereum and ICP.
Key differences
Creation
Ethereum: Smart contracts are written in Solidity and deployed immutably onto the blockchain. ICP: Canisters can be written in any language that complies to Wasm or has an interpreter that can compile to Wasm including Rust, Typescript, Motoko, and Python.
Accounts
Ethereum: On Ethereum, there are two main types of accounts: externally owned accounts (EOAs) and contract accounts. Externally owned accounts, often referred to as wallets, are controlled by anyone with the private key. A contract account is a smart contract deployed to the network.
ICP: Similar to EOA accounts, several wallets support ICP as referenced in this resource.
Similar to the concept of contract accounts, ICP canisters themselves can hold ICP and ICRC1/ICRC2 tokens on ICP. The canister ID serves as a principal or unique identifier that allows you to send tokens to. ICP canisters can generate multiple ECDSA-based public keys using Threshold ECDSA.
Deployment
Ethereum: Developers typically use development frameworks like Hardhat or Truffle to compile and deploy their smart contracts.
ICP: Developers use dfx
which is a similar development environment. dfx
is a command-line tool that interacts with the IC SDK and allows developers to compile and deploy their canisters.
Testing
Ethereum: Developers can utilize testnets such as Sepolia for deploying and testing smart contracts before deploying to the mainnet.
ICP: Currently, testing is done in the local environment. A playground environment on the mainnet is available for canisters, but deployment time is limited to 20 minutes. However, the ability to upgrade and delete canisters on the mainnet allows developers greater flexibility to iterate and refine their smart contracts than on Ethereum.
Paying for gas
Ethereum: Users pay for gas fees directly using the crypto wallet they connect to the dapp. ICP: Using the reverse gas model, the dapp developers, not the users, pay for the gas fees. The reverse gas model aims to provide a smoother user experience by eliminating upfront fees.
Updates
Ethereum: Smart contracts are immutable. To update functionalities, developers need to create a new smart contract and migrate data. ICP: Developers can create upgradeable or non-upgradable (also known as "blackholed") canisters. Upgradable canisters allow updates by reinstalling the code or deploying a new version. Non-upgradable canisters are similar to Ethereum smart contracts.
Consensus
Ethereum: Ethereum uses proof of stake as its consensus mechanism. ICP: The IC consensus protocol provides cryptographically guaranteed finality. The approach on ICP solves the drawbacks of probabilistic finality used in Bitcoin-like protocols, including slow finality times. ICP ensures faster and more secure transaction finality.
Resources
The Internet Computer for Ethereum Developers blog post by Dominic Wörner
Internet Computer Guide for Ethereum Developers by Jennifer Tran