Create a ERC20 token on the Cronos zkEVM Testnet blockchain
Cronos released Cronos zkEVM recently. Cronos zkEVM is a hyperchain based on ZK Stack technology. It is a zero-knowledge powered layer-2 rollup on top of Ethereum Sepolia Testnet. You can read the documentation here.
How to interact with Cronos zkEVM?
In order to connect your wallet to Cronos zkEVM, you can use the following network configuration in MetaMask:
Name: Cronos zkEVM Testnet
New RPC URL: https://rpc-zkevm-t0.cronos.org
Chain ID: 282
Symbol: TCRO
Block explorer URL: https://zkevm-t0.cronos.org/explorer/
Deploy ERC20 tokens to Cronos zkEVM
If you are planning to deploy a ERC20 token on Cronos zkEVM, keep in mind that there are two ways to do this:
Deploy directly on the L2: this approach is simple to implement, but in that case, the ERC20 token won’t be supported natively by the hyperbridge between L1 and L2, and between hyperchains. A custom bridge will be required to withdraw or transfer tokens from the L2.
Deploy first on the L1, then deposit to the L2: this approach requires several steps, but its advantage is that the tokens will be natively supported by the hyperbridge between L1 and L2. They can be deposited into the L2, or withdrawn from the L2, at will. That is the core principle of a layer 2: tokens exist natively on Ethereum, and they are deployed to L2s via the hyperbridge.
In this boilerplate, we demonstrate both approaches.
As explained in the README.file, to deploy a smart contract directly to L2, we can use the usual Hardhat command line instruction, such as:
npx hardhat deploy-zksync --network cronosZkevmSepoliaTestnet --script erc20/deploy.ts
By contrast, to deploy a smart contract to L1 and then deposit the tokens from L1 to L2, we need to follow a 2-step process:
# Deploy on Ethereum Sepolia
npx hardhat run deploy/erc20/deploy_l1.ts --network ethereumSepoliaTestnet
# Then, deposit tokens from L1 to L2
npx ts-node scripts/bridge_cronos_zkevm.ts
The bridge_cronos_zkevm.ts script includes explanatory comments, as well as several additional functions that can serve as references in order to deposit or withdraw either CRO or ERC20 tokens between L1 (Ethereum Sepolia Testnet) and L2 (Cronos zkEVM).
Note 1: Before depositing from Ethereum Sepolia to Cronos zkEVM Testnet, you need to have a sufficient amount of TCRO on your wallet on Ethereum Sepolia, in order to pay for gas on Cronos zkEVM Testnet during the deposit.
Note 2: The script used to deposit ERC20 from L1 to Cronos zkEVM L2 differs somewhat from the documentation provided by zkSync to deposit ERC20 from L1 to zkSync Era. This is because Cronos zkEVM uses a custom protocol token (Testnet CRO instead of ETH), which means that some of the wrapping functions provided by zkSync do not work. Hence we cannot use some of the abstractions provided by the zkSync SDK and are calling smart contract functions directly.
Enjoy!