Using Hardhat
Step 1: Installing Hardhat Verify Package
The first step is to integrate verification capabilities into your Hardhat environment. This is achieved by installing the @nomicfoundation/hardhat-verify plugin. Run the following command in your project's root directory:
Copy
Step 2: Configuring Hardhat
With the verification plugin installed, you need to import it and enable Sourcify integration in your hardhat.config.ts
. This configuration aids in the verification process by ensuring your source code is published and verified through Sourcify. Add the following lines to your hardhat.config.ts:
Copy
You hardhat.config file should look something like this:
TypeScriptCopy
Step 3: Verifying Your Contract
With your project configured for verification, you're ready to verify your smart contract on the Milo network. Replace <contract-address> with the actual address of your deployed contract. The command below initiates the verification process:
For Testnet Verification
If your contract is on the Milo testnet, use the following command, replacing CONTRACT_ADDRESS
with your contract's actual address:
Copy
For Mainnet Verification
For contracts deployed on the Milo mainnet, the command adjusts slightly to point to the mainnet explorer:
Copy
NB: Ensure the network name in your command aligns with your hardhat.config.ts
setup.
This command communicates with the Milo network (as defined in your Hardhat configuration) and submits your contract's source code and metadata for verification. Upon successful verification, your contract's source code will be publicly visible on the blockchain, associated with its on-chain address. You should get a similar response to the one below:
Conclusion
Verifying your smart contract on Milo using Hardhat not only enhances the transparency and credibility of your project but also significantly improves the end-user experience by facilitating easier interactions and verifications. Following the steps outlined in this guide, developers can ensure their contracts are verified and open for scrutiny, fostering a more secure and trustworthy ecosystem.
Last updated