Via hardhat plugin
Hardhat is a full-featured development environment for contract compilation, deployment and verification. The Hardhat Etherscan plugin supports contract verification on U2U Chain blockchain explorer.
Sample Hardhat Project
1) Install Hardhat
If you are starting from scratch, create an npm project by going to an empty folder (npm version 7 or higher is recommended):
Once your project is ready:
npm instructions
2) Create a project
Run npx hardhat init
in your project folder and follow the instructions to create (more info here).
If you select Create a Typescript project, a simple project creation wizard will ask you some questions, please proceed with all "y" (yes).
After that, the wizard will create a sample project with some directories and files and install the necessary dependencies. The initialized project has the following structure:
Config File
Your basic Hardhat config file (hardhat.config.js
or hardhat.config.ts
) will be setup to support the network you are working on.
Here we add an RPC url without an API key, however some value is still required. You can use any arbitrary string. More info.
Deploy and Verify
Deploy
Verify
You can include constructor arguments with the verify task.
In that:
DEPLOYED_CONTRACT_ADDRESS
: your deployed contract address[ARG_1 ARG_2 ...]
: arguments that have been passed to the constructor or initialize function. More detail please see:
Back to our sample project, you can take a look at contract verification:
After the task is successfully executed, you'll see a link to the publicly verified code of your contract.
Resources
Read more: https://hardhat.org/hardhat-runner/docs/guides/verifying
Last updated