Hardhat
Verify your SmartContract using Hardhat
Verifying Your Contracts on Lumia L2
After you've deployed your contract to the Lumia L2 network, the next crucial step is to verify its source code. Verifying a contract involves making its source code publicly available, along with the compiler settings used, allowing anyone to compile it and compare the generated bytecode with the deployed version on the blockchain. This transparency is essential in an open platform like Lumia L2.
In this guide, we'll walk you through the process of verifying your contract using the Lumia L2 Explorer.
Installation
If starting from scratch, create a new npm project in an empty folder using
npm init
(npm 7 or higher recommended).Install Hardhat by running
npm install --save-dev hardhat
oryarn add --dev hardhat
.Create a Hardhat project by running
npx hardhat
and following the prompts.Install the hardhat-verify plugin (v3.0.0+) using
npm install --save-dev @nomicfoundation/hardhat-verify
oryarn add --dev @nomicfoundation/hardhat-verify
.Add the plugin reference to your
hardhat.config.js
orhardhat.config.ts
file.
Configuration
Set up your Hardhat config file to support the network you're working on (e.g., Lumia Testnet).
Add an RPC URL with an arbitrary string as the API key.
To use BlockScout for verification, specify the explorer details under a
customChains
object, including thechainID
,apiURL
, andbrowserURL
.
Deployment and Verification
Use Hardhat Ignition for deployment.
Deploy your contract.
Verify the deployed contract using:
npx hardhat verify --network lumia-testnet DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1"
.
If the contract is automatically verified via the Ethereum Bytecode Database service, you may need to use the --force
flag to enforce verification.
Confirming Verification on BlockScout
Go to your Lumia Testnet URL and search for the contract address.
Check for a green checkmark ✅ indicating the contract is verified.
Scroll down to view and interact with the contract code.
Last updated