Contract Deployment and Verification
Contract Deployment
Like zkSync Era, Cronos zkEVM recommends the use of:
Hardhat for smart contract development
Node Typescript with the ethers library for backend and frontend development
While the zkSync docs are the most comprehensive and up to date source of information, you can also refer to this linked repository, created especially for Cronos zkEVM Chain, which shows how to read the blockchain, write on the blockchain, and develop smart contracts:
Refer to the README.md file for a list of frequently used commands.
The typical network configuration parameters are shown in the hardhat.config.ts file.
The scripts directories contain some useful examples of scripts and functions that you may need to execute calls and transactions.
Contract Verification
In order to enable users and fellow developers to do their own research, it is imperative that you publish your smart contract code on Cronos zkEVM Explorer.
The Cronos zkEVM Explorer supports smart contract verification either through the web interface or programmatically via Hardhat (we recommend to use Hardhat).
Contract Verification Via Hardhat:
Cronos zkEVM is supported by Hardhat out of the box, to verify contract using Hardhat, we will need:
Configure the network parameters in
hardhat.config.js
, referring to this guide. As an example, theverifyURL
for mainnet should be set as
A "Developers Portal" API key, refer to below guides on how to register and obtain one.
Cronos zkEVM Mainnet: https://explorer-api-doc.zkevm.cronos.org/mainnet/index.html#overview
Cronos zkEVM Testnet: https://explorer-api-doc.zkevm.cronos.org/testnet/index.html#overview
We can also refer to the example provided in this boilerplate repository.
Note: During the contract verification Via Hardhat - Please install and use @matterlabs/hardhat-zksync-verify
version 1.7.1+ instead of hardhat-etherscan
After the contract verification is complete, the Cronos zkEVM Explorer will display details about your smart contract code.
Contract Verification Via Explorer interface:
For verification via the web interface, visit the following URLs:
Note that when using contract verification via the explorer interface, Standard-Json-Input
method is required. Reference for the JSON file format:https://docs.soliditylang.org/en/latest/using-the-compiler.html#input-description
Important note about tokens
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 two 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. When the first token is deposited from L1 to L2, the hyberbridge automatically creates a ERC20 smart contract on L2, which is the representation of the L1 token on the L2.
After deploying your smart contract, you will need to publish and verify its code in the block explorer:
If you have deployed directly on the L2, the deployment script included in the boilerplate project performs the contract code publication and verification automatically.
If you deploy first on the L1 (Ethereum Sepolia), you can publish and verify the contract code on the Etherscan Sepolia block explorer as usual. With respect to publishing and verifying the code of the L2 smart contract created by the hyperbridge, this is not yet supported.
Last updated