Hardhat is a full-featured development environment for contract compilation, deployment and verification. The hardhat-verify plugin supports contract verification on Quaiscan.
Get Started
1) Install Hardhat
If you are starting from scratch, create an npm project by going to an empty folder, running npm init, and following the instructions. Recommend npm 7 or higher.
Once your project is ready:
npm instructions
npm install --save-dev hardhat
yarn instructions
yarn add --dev hardhat
2) Create a project
Run npx hardhat in your project folder and follow the instructions to create (more info here).
Your basic Hardhat config file (hardhat.config.js or hardhat.config.ts) will be setup to support the network you are working on. In this example we use the Optimism Sepolia test network and a .js file.
Here we add an RPC url without an API key, however some value is still required. You can use any arbitrary string. More info.
If you prefer, you can migrate to hardhat-toolbox to use a plugin bundle.
In order to use Quaiscan explorer for the verification, you have to specify the explorer details under a customChains object. It includes:
chainID - Quai Network ChainID
apiURL - Quaiscan API URL
browserURL - Quaiscan Web URL
For example, here we added Quaiscan api endpoints for Quai Network to the config file. Note the network name in customChains must match the network name in the apiKey object.
Deploy and Verify
For deployment we will use Hardhat Ignition - built-in Hardhat deployment system.
Deploy
Verify
The plugin requires you to include constructor arguments with the verify task and ensures that they correspond to expected ABI signature. However, Quaiscan ignores those arguments, so you may specify any values that correspond to the ABI.
Optimism Sepolia example.
Confirm Verification on Quaiscan
Go to your Quaiscan instance and paste the contract address into the search bar.
Scroll down to see verified status. A green checkmark β means the contract is verified.
Scroll down to see and interact with the contract code.
> npx hardhat verify --network quai 0x00126b33e425f99ce962ACB91752DB41F302EFEA 1234
Successfully submitted source code for contract
contracts/Lock.sol:Lock at 0x00126b33e425f99ce962ACB91752DB41F302EFEA
for verification on the block explorer. Waiting for verification result...
Successfully verified contract Lock on the block explorer.
https://quaiscan.io/address/0x00126b33e425f99ce962ACB91752DB41F302EFEA#code