Cookie Consent by Free Privacy Policy Generator Aktuallisiere deine Cookie Einstellungen ๐Ÿ“Œ How to Verify Smart Contracts on BlockScout with Hardhat


๐Ÿ“š How to Verify Smart Contracts on BlockScout with Hardhat


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Verifying a smart contract on Blockscout makes the contract source code publicly available and verifiable, which creates transparency and trust in the community.

This guide will walk you through verifying a smart contract on Blockscout with Hardhat.

Prerequisites

Before you begin the steps in this guide, please ensure you have the following:โ€‹

  • You should have a Hardhat project initialized on your machine.

  • An Etherscan Account. Don't have one? go to Etherscan and sign up for an account.

Verifying the Smart Contract using Hardhat

Step 1: Install the Hardhat-Verify Plugin

The hardhat-verify plugin helps you verify the source code for your Solidity contracts.

In your project directory, install hardhat-verify

npm install --save-dev @nomicfoundation/hardhat-verify

And add the following statement to your hardhat.config.js:

require("@nomicfoundation/hardhat-verify");

Or, if you are using TypeScript, add this to your hardhat.config.ts:

import "@nomicfoundation/hardhat-verify";

Step 2: Configure Hardhat

Add the following configuration to the config object in hardhat.config.js.

 etherscan: {
    // Your API key for Etherscan
    // Obtain one at https://etherscan.io/
    apiKey: {
      mode: '<ETHERSCAN_API_KEY>',
    },
    customChains: [
      {
        network: 'mode',
        chainId: 919,
        urls: {
          apiURL: 'https://sepolia.explorer.mode.network/api\?',
          browserURL: 'https://sepolia.explorer.mode.network',
        },
      },
    ],
  },

Replace <ETHERSCAN_API_KEY> with your API key for Etherscan. Under your Etherscan account settings, find the โ€œAPI Keysโ€ section. Generate one API key using the Free Plan.

This is what the hardhat.config.js file looks like:

require('@nomicfoundation/hardhat-toolbox');

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: {
    version: '0.8.19',
    settings: {
      evmVersion: 'london',
    },
  },
  networks: {
    'mode': {
      url: 'https://sepolia.mode.network',
      chainId: 919,
      accounts: ['<MY_PRIVATE_KEY>'],
      gasPrice: 10000,
    },
  },
  etherscan: {
    apiKey: {
      mode: '<ETHERSCAN_API_KEY>',
    },
    customChains: [
      {
        network: 'mode',
        chainId: 919,
        urls: {
          apiURL: 'https://sepolia.explorer.mode.network/api\?',
          browserURL: 'https://sepolia.explorer.mode.network',
        },
      },
    ],
  },
};

Step 3: Deploying and Verifying Contracts

Deploy the Contract

In your terminal, run the following command:

npx hardhat run scripts/deploy.js --network mode

Ensure you have enough funds in your account to pay for Gas. You can grab some test tokens from the Faucet to test your contracts before deploying to the mainnet.

Once your smart contract has been successfully deployed, we can now proceed to verify the contract using the contract address.

Verify the contract

In your terminal, run the verify task, passing the address of the contract, the network where it's deployed, and the constructor arguments that were used to deploy it (if any):

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

Where DEPLOYED_CONTRACT_ADDRESS is the contract of your deployed smart contract. Also, replace "Constructor argument 1" (keep the quotes) with the arguments you passed to your smart contract when deploying.

If you are using complex constructor arguments, reference the following Hardhat Documentation.

Conclusion

Congratulations! In this guide, weโ€™ve covered how to verify smart contracts on Blockscout with Hardhat using the hardhat-verify plugin that simplifies the process. Verifying smart contracts is a crucial step in the deployment process because it allows the community to review the source code before usage, thereby promoting transparency and trust within the community.

What's Next:

Check out these other resources from the Mode C00perators:

...



๐Ÿ“Œ How to Verify Smart Contracts on BlockScout with Hardhat


๐Ÿ“ˆ 97.68 Punkte

๐Ÿ“Œ How to Verify Smart Contracts on BlockScout with Hardhat


๐Ÿ“ˆ 97.68 Punkte

๐Ÿ“Œ Smart Contracts May Be Smart, But Are They Contracts?


๐Ÿ“ˆ 39.51 Punkte

๐Ÿ“Œ Smart Contracts Step-by-Step: A Beginnerโ€™s Guide to Debugging and Deploying Smart Contracts with Infura and Truffle


๐Ÿ“ˆ 39.51 Punkte

๐Ÿ“Œ Smart Contracts Step-By-Step: A Beginnerโ€™s Guide To Debugging and Deploying Smart Contracts With Infura and Truffle


๐Ÿ“ˆ 39.51 Punkte

๐Ÿ“Œ Smart Contracts 2.0: The Evolution of Smart Contracts


๐Ÿ“ˆ 39.51 Punkte

๐Ÿ“Œ How to Register a Smart Contract to Mode SFS with Hardhat.


๐Ÿ“ˆ 34.7 Punkte

๐Ÿ“Œ EIP 712: A simple example using Ethers.js & Hardhat


๐Ÿ“ˆ 29.95 Punkte

๐Ÿ“Œ Ethereum Development: Foundry or Hardhat


๐Ÿ“ˆ 29.95 Punkte

๐Ÿ“Œ Ping Identity unveils PingOne Verify to help customers verify identity while reducing fraud


๐Ÿ“ˆ 27.03 Punkte

๐Ÿ“Œ Pay.Google.com Verify Payment | How to Verify Your GPay Payment Method


๐Ÿ“ˆ 27.03 Punkte

๐Ÿ“Œ Writing Smart Contracts using Vyper, Remix IDE and deploying them on BNB Smart Chain.


๐Ÿ“ˆ 24.51 Punkte

๐Ÿ“Œ Smart Contracts als Zukunft der Blockchain


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Smart Contracts als Zukunft der Blockchain


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Blockchains, Smart Contracts und ICOs: Wo stehen wir?


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ DEF CON 25 - Konstantinos Karagiannis - Hacking Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Lehren aus dem DAO-Hack: Wieso Smart Contracts die Erwartungen enttรคuschen mรผssen


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Lehren aus dem DAO-Hack: Wieso Smart Contracts die Erwartungen enttรคuschen mรผssen


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Smart Contracts 101? How This Emerging Technology Works


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Forscher finden 34.000 Sicherheitslรผcken in Smart Contracts auf Ethereum


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Security Vulnerabilities in Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ APPSEC Cali 2018 -Predicting Random Numbers in Ethereum Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ APPSEC Cali 2018 -Predicting Random Numbers in Ethereum Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Easterhegg 2018 - Smart Contracts on Ethereum (Workshop)


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Smashing Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ DEF CON 25 - Matt Suiche - Porosity A Decompiler For Blockchain Based Smart Contracts Bytecode


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ 34C3 - cryptocurrencies, smart contracts, etc.: revolutionary tech?


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ 34C3 - cryptocurrencies, smart contracts, etc.: revolutionary tech? - deutsche รœbersetzung


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ B2B-Komplettlรถsung fรผr Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Building And Deploying Ethereum Smart Contracts With Solidity and JavaScript


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ 6 Common Misconceptions About the Security of Blockchain Technology and Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Mit Smart Contracts zur Industrie 4.0


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ AppSec US 2018 - Intro to Hacking Decentralized Applications and Smart Contracts


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Outsmarting Smart Contracts - Damian Rusinek


๐Ÿ“ˆ 19.75 Punkte

๐Ÿ“Œ Manticore - Symbolic Execution Tool For Analysis Of Binaries And Smart Contracts


๐Ÿ“ˆ 19.75 Punkte











matomo