Verifying Contract on Quaiscan
A guide to verifying your smart contracts on Quaiscan.
Introduction
This article shows how to verify a smart contract on Quai Network’s block explorer Quaiscan.
Prerequisites
To deploy contracts and verify them on Quaiscan we’ll need a few dependencies. Here’s an overview of all the main dependencies we’ll be using.
NodeJS | Javascript runtime environment. Use the LTS version. |
hardhat-example | A Hardhat project with sample contracts and deploy scripts for Quai Network. |
hardhat-deploy-metadata | A plugin for hardhat that uploads contract metadata to IPFS |
Quais.js | A JavaScript library for interacting with Quai Network. |
Walkthrough
Today we’re going to be verifying a smart contract on Quaiscan, Quai Network’s block explorer.
This guide follows the Deploy with Solidity guide, so make sure you’re familiar with that and the hardhat-example repo before beginning.
Deploy a Smart Contract
Following the Deploy with Solidity guide, deploy a smart contract complete with IPFS metadata.
When using the hardhat-example repo the command should be npx hardhat run scripts/deployERC20.js
which produces output similar to the following:
In the above output you’ll see that the contract’s metadata was uploaded to ipfs.qu.ai
with the following hash: QmPCoBa1bCFmRoTD7GuexJqBAy7pqg8J4b8B48q5DgxUEV
Your hash will be different. Make sure you capture it as we’ll need it in the next step.
Download the IPFS metadata
When using the hardhat-deploy-metadata plugin, the IPFS metadata is stored in the project under the metadata
folder, but isn’t formatted properly for Quaiscan.
We’ll need to download the proper format from IPFS to upload into Quaiscan and verify our contract.
Run the following command using your IPFS hash when you deployed your contract to download the metadata and save it as ipfsMeta.json
.
Verify Smart Contract on Quaiscan
Now that we have a deployed smart contract and the IPFS metadata in proper JSON formatting, we can verify our smart contract on Quaiscan.
Open your browser and visit the Verify Contract page on Quaiscan.
Using this page fill in all the details of your contract exactly as it’s been written.
You’ll need the correct contract address and license indicated by the SPX-License-Identifier
in your contract’s code.
Select Solidity (Standard JSON input) as the Verification Method and the correct version of the Solidity Compiler used to compile your contract.
Finally upload ipfsMeta.json
and click Verify & Publish to verify your smart contract.
Once successful you can visit your contract’s page on Quaiscan to interact with it directly and see it’s verification status.
Congratulations! You have just verified your smart contract on Quaiscan!