Deploy & verify smart contracts on the Cronos blockchain using Hardhat
Hardhat is probably the most widely adopted smart contract development and testing framework. Cronos, as an EVM compatible blockchain, is of course fully supported by hardhat.
Getting started
Many dapp developers have asked for a quick and easy hardhat boilerplate repository that they can use to develop, deploy and verify smart contracts on the Cronos blockchain.
You can access the boilerplate here, and check out the README.md file for installation and deployment instructions.
Hardhat configuration
As you would expect, all required customizations are done in the hardhat.config.js
file.
This is where you can define the networks:
cronos: {
url: "https://evm.cronos.org/",
chainId: 25,
accounts: [myPrivateKey],
gasPrice: 10100000000000,
},
cronosTestnet: {
url: "https://evm-t3.cronos.org/",
chainId: 338,
accounts: [myPrivateKey],
gasPrice: 10100000000000,
},
Verification settings
The contract verification settings can be found in the hardhat.config.js
file:
etherscan: {
apiKey: {
mainnet: <string>process.env["ETHERSCAN_API_KEY"],
sepolia: <string>process.env["ETHERSCAN_API_KEY"],
cronos: <string>process.env["CRONOS_EXPLORER_MAINNET_API_KEY"],
cronosTestnet: <string>process.env["CRONOS_EXPLORER_TESTNET_API_KEY"],
},
customChains: [
{
network: "cronos",
chainId: 25,
urls: {
apiURL: "https://explorer-api.cronos.org/mainnet/api/v1/hardhat/contract",
browserURL: "https://explorer.cronos.org",
},
},
{
network: "cronosTestnet",
chainId: 338,
urls: {
apiURL: "https://explorer-api.cronos.org/testnet/api/v1/hardhat/contract",
browserURL: "https://explorer.cronos.org/testnet",
},
},
],
For contract verification, you need an API key for the Explorer API. Here are the URLs where you can register in order to request an API key:
Cronos Mainnet: https://explorer-api-doc.cronos.org/mainnet/
Cronos Testnet: https://explorer-api-doc.cronos.org/testnet/
Enjoy!