Verify using Hardhat
Verifying a smart contract on the blockchain is an essential step to ensure its transparency, security and ease of interaction for users and other developers.
This project is a demonstration of how to verify a contract on blockscout using hardhat.
1. Clone repository
git clone https://github.com/alt-research/contract-verify-sample.git
2. Navigate to hardhat
folder
cd hardhat
3. Install dependencies
yarn
4. Modify the network
part in hardhat.config.ts
networks: {
testnet: {
url: '', // fill in rpc url
chainId: 123, // fill in sample chain id
accounts: ["0xfed4030d3379f87b009e9011b83c9e89a9d16411b039e7ca718453c2bd0d3aac"],
}
},
5. Configure etherscan
etherscan: {
// dummy key "abc"
apiKey: {
testnet: "abc",
},
customChains: [
{
network: "testnet",
chainId: 123, // sample chain id
urls: {
apiURL: "", // fill in rpc url
browserURL: "" // fill in explorer url
}
},
]
}
6. Deploy sample contract
npx hardhat run deploy.ts
// deploy address = 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
7. Verify sample contract
npx hardhat verify --network testnet 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
8. Confirm verification
After executing the relevant command, visit the Xterio explorer (Mainnet / Testnet) to see your contract's status.