DEV Community

Cover image for Verify Your Smart Contract Code
Neeraj Choubisa
Neeraj Choubisa

Posted on

Verify Your Smart Contract Code

Self-executing contracts, or "smart contracts," are kept on a blockchain. They are implemented on the blockchain network using coding languages like Solidity. Smart contracts are utilised in many blockchain applications, including decentralised finance (DeFi), non-fungible tokens (NFTs), and others, to automate different procedures and transactions.

Why Verify a Smart Contract?

  • Transparency: Decentralisation and transparency are two of the most crucial elements of Web 3. The community gains more trust when you open-source your project's smart contracts, allowing anybody to review the code and make suggestions for changes.

  • Security: After your smart contract has been certified, it will essentially have more eyes on it, and smart contract specialists can find any potential flaws. The disadvantage is that someone (a black hat) might discover the weakness first and use it to abuse your contract.

  • Innovation & acceptance: Since other developers can fork your code, add features, and keep building on top of it, open-sourced code encourages more innovation and acceptance. thereby resulting in a development ecosystem that is more active and has a quick learning curve.

Four Method to Verify Smart Contract

  • Remix IDE
  • Hardhat
  • Ether Scan
  • Brownie

We Discuss the Hardhat Verification in this Blog

Hardhat is a popular smart contract development framework, and it's fairly simple to verify your source code. Note that you'll need an **Etherscan API Key** to verify your source code.

You Need to install
npm install --save-dev @nomiclabs/hardhat-etherscan
in your project

Update your hardhat.config.js file to include the etherscan object and your Etherscan API key.

module.exports = {
  networks: {
    goerli: { ... }
  etherscan: {

Enter fullscreen mode Exit fullscreen mode

Then, run the following command to verify your source code:

npx hardhat verify --network goerli DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1"

That's so simple isn't it ...

Happy Coding ....

Top comments (0)