Submitting your Smart Contract to Etherscan (2024)

You should have completed Part 1: Creating and Deploying a Smart Contract, and Part 2: Interacting with Your Smart Contract prior to starting this section below.

You did all the hard work of bringing your smart contract to life - now it's time to share it with the world!
By verifying your smart contract on Etherscan, anyone can view your source code and interact with your smart contract. Let's get started!

Step 1: Generate an API Key on your Etherscan account

An Etherscan API Key is necessary to verify that you're the owner of the smart contract that you're trying to publish

📘

Register on Etherscan

If you don't have an Etherscan account, first sign up using this link.

Once logged in, press your username on the top right, and select the "My profile" button:

Submitting your Smart Contract to Etherscan (1)

Next, navigate to the "API-KEYs" button on the left tab bar. Then press the "Add" button, name your app whatever you wish (we chose hello-world), and then select continue.

Submitting your Smart Contract to Etherscan (2)

Once you have followed the steps above, you should be able to view your new API key, which we have highlighted in red below. Copy this API key to your clipboard.

Submitting your Smart Contract to Etherscan (3)

Let's update your .env file to include your Etherscan API Key. If you were following the Hardhat tutorial, your .env file should look like this:

API_URL = "https://eth-sepolia.g.alchemy.com/v2/your-api-key"API_KEY = "your-api-key"PRIVATE_KEY = "your-private-account-address"ETHERSCAN_API_KEY = "your-etherscan-key"

Step 2.1 Install the hardhat-etherscan plugin

Publishing your contract to Etherscan with HardHat is super simple. To get started, you will first need to install the hardhat-etherscan plugin to automatically verify your smart contract's source code and ABI on Etherscan. In your hello-world project directory run:

npm install --save-dev @nomiclabs/hardhat-etherscan

Note: If using an earlier version of ethers, i.e., ethers^6.0.0+, you might encounter problems when installing hardhart-etherscan because of the peer depency of hardhat. You can use the --force or --legacy-peer-deps flags to ignore these warning and install hardhat-etherscan, i.e., npm install --save-dev @nomiclabs/hardhat-etherscan --legacy-peer-deps.

Once installed, include the following statement at the top of your hardhat.config.js, and add the Etherscan config options:

/*** @type import('hardhat/config').HardhatUserConfig*/require('dotenv').config();require("@nomiclabs/hardhat-ethers");require("@nomiclabs/hardhat-etherscan");const { API_URL, PRIVATE_KEY } = process.env;const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY;module.exports = { solidity: "0.7.3", defaultNetwork: "sepolia", networks: { hardhat: {}, sepolia: { url: API_URL, accounts: [`0x${PRIVATE_KEY}`] } }, etherscan: { // Your API key for Etherscan // Obtain one at https://etherscan.io/ apiKey: ETHERSCAN_API_KEY }};

Step 2.2 Verify your smart contract on Etherscan!

Make sure your files are properly saved (especially if you're in VSCode) and your .env variables are properly configured.

Finally, run the verify task, passing the address of the contract and the first message argument string that we deployed it with:

npx hardhat verify --network sepolia DEPLOYED_CONTRACT_ADDRESS 'Hello World!'

📘

Address Verification

Make sure that DEPLOYED_CONTRACT_ADDRESS is the address of your deployed smart contract on the Sepolia test network. Also, the last argument, 'Hello World!' must be the same string value that you used during the deploy step in Part 1.

If all goes well, you should see the following message in your terminal:

Successfully submitted source code for contractcontracts/HelloWorld.sol:HelloWorld at 0xdeployed-contract-addressfor verification on Etherscan. Waiting for verification result...Successfully verified contract HelloWorld on Etherscan.https://sepolia.etherscan.io/address/<contract-address>#contracts

Congrats! Your smart contract code should be on Etherscan! Check out Step 3 to see how to view your smart contract code!

When you navigate to the link provided in your terminal, you should be able to see your smart contract code and ABI published on Etherscan!

Wahooo - you did it champ! Now, anyone can call or write to your smart contract! We can't wait to see what you build next!

Once you complete this tutorial, let us know your experience or if you have any feedback by tagging us on Twitter @alchemyplatform!

Updated about 1 year ago

Submitting your Smart Contract to Etherscan (2024)
Top Articles
Is It Permissible to Study Futures Contracts? - Islam Question & Answer
Anonymous Browsing: How To Browse Anonymously In 2024
Rosy Boa Snake — Turtle Bay
Exam With A Social Studies Section Crossword
Is Sportsurge Safe and Legal in 2024? Any Alternatives?
Nm Remote Access
Regular Clear vs Low Iron Glass for Shower Doors
Aspen.sprout Forum
Belly Dump Trailers For Sale On Craigslist
The Banshees Of Inisherin Showtimes Near Regal Thornton Place
National Office Liquidators Llc
Crossword Nexus Solver
Images of CGC-graded Comic Books Now Available Using the CGC Certification Verification Tool
Spectrum Field Tech Salary
Praew Phat
Craigslist Missoula Atv
Evil Dead Rise - Everything You Need To Know
Healthier Homes | Coronavirus Protocol | Stanley Steemer - Stanley Steemer | The Steem Team
Robin D Bullock Family Photos
Menards Eau Claire Weekly Ad
Iroquois Amphitheater Louisville Ky Seating Chart
Poe Str Stacking
Somewhere In Queens Showtimes Near The Maple Theater
Craigslist Northfield Vt
Www.dunkinbaskinrunsonyou.con
Www.patientnotebook/Atic
Craigslist Maryland Trucks - By Owner
Rs3 Ushabti
Vivaciousveteran
Piri Leaked
Drying Cloths At A Hammam Crossword Clue
Hdmovie2 Sbs
800-695-2780
Firefly Festival Logan Iowa
Account Now Login In
Publix Daily Soup Menu
Brenda Song Wikifeet
Spy School Secrets - Canada's History
Teenbeautyfitness
Synchrony Manage Account
One Main Branch Locator
Daly City Building Division
Scarlet Maiden F95Zone
Locate phone number
Courses In Touch
Marcal Paper Products - Nassau Paper Company Ltd. -
1990 cold case: Who killed Cheryl Henry and Andy Atkinson on Lovers Lane in west Houston?
Unpleasant Realities Nyt
Is Chanel West Coast Pregnant Due Date
Kenmore Coldspot Model 106 Light Bulb Replacement
Divisadero Florist
Morgan State University Receives $20.9 Million NIH/NIMHD Grant to Expand Groundbreaking Research on Urban Health Disparities
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 5633

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.