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
Canada’s first ETF especially for retirees has been around for a year now: Here’s what we’ve learned about it
Los aspectos más destacados de los ETF de Japón - Crypto Economy ESP
Where To Go After Howling Pit Code Vein
Skyward Sinton
Craglist Oc
Caroline Cps.powerschool.com
Hotels Near 500 W Sunshine St Springfield Mo 65807
Flights to Miami (MIA)
Mawal Gameroom Download
Evita Role Wsj Crossword Clue
Joe Gorga Zodiac Sign
Www.paystubportal.com/7-11 Login
Keurig Refillable Pods Walmart
Hope Swinimer Net Worth
About Us | TQL Careers
Mini Handy 2024: Die besten Mini Smartphones | Purdroid.de
2015 Honda Fit EX-L for sale - Seattle, WA - craigslist
Best Suv In 2010
Unlv Mid Semester Classes
24 Hour Drive Thru Car Wash Near Me
2020 Military Pay Charts – Officer & Enlisted Pay Scales (3.1% Raise)
Royal Cuts Kentlands
Teacup Yorkie For Sale Up To $400 In South Carolina
Lisas Stamp Studio
Understanding Gestalt Principles: Definition and Examples
Drift Hunters - Play Unblocked Game Online
Barista Breast Expansion
Villano Antillano Desnuda
Ts Modesto
Does Royal Honey Work For Erectile Dysfunction - SCOBES-AR
Ff14 Sage Stat Priority
Shauna's Art Studio Laurel Mississippi
Magicseaweed Capitola
10 games with New Game Plus modes so good you simply have to play them twice
Labyrinth enchantment | PoE Wiki
„Wir sind gut positioniert“
Google Flights Orlando
Exploring the Digital Marketplace: A Guide to Craigslist Miami
Craigslist Minneapolis Com
Sound Of Freedom Showtimes Near Amc Mountainside 10
Rocket Lab hiring Integration &amp; Test Engineer I/II in Long Beach, CA | LinkedIn
Unblocked Games - Gun Mayhem
Sherwin Source Intranet
Iron Drop Cafe
300+ Unique Hair Salon Names 2024
Rocket Bot Royale Unblocked Games 66
Minecraft Enchantment Calculator - calculattor.com
The Missile Is Eepy Origin
Ff14 Palebloom Kudzu Cloth
211475039
The Love Life Of Kelsey Asbille: A Comprehensive Guide To Her Relationships
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.