This section is a guide on how to verify a smart contract on the B² Network using Hardhat. Hardhat is a popular smart contract development frameworks. It is used in the B² rollup as a default for deploying and automatically verifying smart contracts.
Run the following command in the command line to install the hardhat-verify plugin:
npm install --save-dev @nomicfoundation/hardhat-verify
require("@nomicfoundation/hardhat-verify");
module.exports = {
// ...
networks: {
B2Mainnet: {
url: 'https://rpc.bsquared.network',
chainId: 223,
accounts: {
"your_private_key",
},
},
},
etherscan: {
apiKey: {
B2Mainnet: "no-api-key-needed"
},
customChains: [
{
network: "B2Mainnet",
chainId: 223,
urls: {
apiURL: "https://explorer.bsquared.network/api",
browserURL: "https://explorer.bsquared.network/"
}
},
]
},
// ...
};Compile your smart contract using Hardhat by running the following command:
npx hardhat compile
Deploy your smart contract using Hardhat as you normally would.
Run the following command to verify your smart contract:
npx hardhat verify --network B2Mainnet CONTRACT_ADDRESS "Constructor argument 1" "Constructor argument 2" ...
Replace CONTRACT_ADDRESS with the address of your deployed contract. If your contract has constructor arguments, include them after the contract address.
After running the verification command, you will receive a verification request ID. You can use this ID to check the status of your verification on the block explorer.