Verify a contract - Polygon Knowledge Layer (2024)

Once a smart contract is deployed to zkEVM, it can be verified in various ways depending on the framework of deployment as well as the complexity of the contract. The aim here is to use examples to illustrate how you can manually verify a deployed smart contract.

Ensure that your wallet is connected while following this guide. Although any wallet can be used, we use Metamask wallet throughout this tutorial.

Manual verification

After successfully compiling a smart contract, follow the next steps to verify your smart contract.

  1. Copy the address to which the smart contract is deployed.

  2. Navigate to the zkEVM Explorer and paste the contract address into the Search box. This opens a window with a box labelled Contract Address Details.

  3. Scroll down to the box with tabs labelled Transactions, Internal Transactions, Coin Balance History, Logs, and Code.

  4. Click the Transaction Hash in the Contract Creation box, which is the super long number.

  5. Select the Code tab.

  6. Click the Verify and Publish button.

  7. There are 3 options to provide the Contract’s code. We dive into the Flattened source code and Standard input JSON options.

Flattened source code

Click Next after selecting the via Flattened Source Code option.

Various frameworks have specific ways to flatten the source code. Our examples are Remix and Foundry.

Using Remix

In order to flatten the contract code with Remix, one needs to only right-click on the contract name and select Flatten option from the drop-down menu that appears. See the below figure for reference.

Verify a contract - Polygon Knowledge Layer (1)

After selecting Flatten, a new .sol file with the suffix _flatten.sol is automatically created. Copy the contents of the new <Original-Name>_flatten.sol file and paste into the Enter the Solidity Contract field in the explorer.

Using Foundry

In order to flatten the code using Foundry, the following command can be used:

 forge flatten src/<Contract-Name> -o <Any-Name-For-Flattened-Code>.sol

With this command, the flattened code gets saved in the <Any-Name-For-Flattened-Code>.sol file. Copy the contents of the new <Any-Name-For-Flattened-Code>.sol file and paste into the Enter the Solodity Contract field in the explorer.

Standard input JSON

Click Next after selecting the via Standard Input JSON option.

  1. In order to update the Compiler based on your contract’s compiler version,

    • Click the ↓ for a list of compiler versions.
    • Select the corresponding version. For example, select v0.8.9+commit.e5eed63a if your code has pragma solidity ^0.8.9;.
  2. Paste the Standard input JSON file into the Drop the standard input JSON file or Click here field. You can find it in your local project folder.

    • The Standard input JSON file is the {"superlongnumberfile"}.json in the build-info subfolder. Path example: fullstack-zkevm/src/build-info/{"superlongnumberfile"}.json
    • Save this file to parse it with Prettier
    • Find the input JSON object. It looks something like this"input": {}
    • Copy the input object value into a new file
    • Name and save this file locally in the root folder. Check this example file for reference
    • Drag and drop the Standard Input JSON file into Drop the standard input JSON file or Click here field. Once pasted, the Verify & Publish button becomes active.
  3. Since you have provided an input, set Try to fetch constructor arguments automatically to No.

  4. To add your ABI-encoded constructor arguments:

    • Open the Online ABI Encoder
    • Choose the Auto-parse tab.
    • Copy the ABI-encoded output.
    • Paste it into ABI-encoded Constructor Arguments if required by the contract.

Once you paste the contents of the newly created .sol file to the Enter the Solidity Contract field, the Verify & Publish button becomes active.

Click on Verify & Publish to verify your deployed smart contract.

Verify using Remix

We use the ready-made Storage.sol contract in Remix. Compile the contract and follow the steps provided below.

  1. Deploy the Storage.sol contract:

    • Click the Deploy icon on the left-side of the IDE window.
    • Change ENVIRONMENT to “Injected Provider - MetaMask” (ensure that your wallet is already connected to Sepolia network).
    • Confirm the connection request when MetaMask pops up.
    • Click the Deploy button and confirm.
  2. Check the deployed smart contract on Etherscan:

    • Copy the contract address below the Deploy Contracts.
    • Navigate to the Sepolia explorer.
    • Paste the contract address in the Search by address field and press ENTER.
    • Click on the Transaction Hash to see transaction details.
  3. You are going to need your Etherscan API Key in order to verify.

    • Login to Etherscan.
    • Hover the cursor over your username for a drop-down menu.
    • Select API Keys.
    • Click API Keys again below the Others option.
    • Copy the API Key.
  4. Next, in the Remix IDE:

    • Click Plugin Manager icon on the bottom-left corner of the Remix IDE.

    • Type Etherscan in the search field at the top.

    • Click Activate button as the Etherscan option appears. An Etherscan icon should appear on the left-side of the IDE.

    • Click on the Etherscan icon.

    • Ensure that Sepolia is present in the Selected Network field.

    • Click within the Contract Name field and type in the name of your deployed contract, or select it if it appears.

    • Paste the address in the Contract Address field.

    • Verify button becomes active if all information has been provided.

    • Click the Verify button to complete verification of your smart contract.

Verify a contract - Polygon Knowledge Layer (2024)
Top Articles
Your Guide to B2C Customer Service
What Is A Good Credit Card APR?
2018 Jeep Wrangler Unlimited All New for sale - Portland, OR - craigslist
English Bulldog Puppies For Sale Under 1000 In Florida
It may surround a charged particle Crossword Clue
Odawa Hypixel
News - Rachel Stevens at RachelStevens.com
Free Atm For Emerald Card Near Me
Sissy Transformation Guide | Venus Sissy Training
Hay day: Top 6 tips, tricks, and cheats to save cash and grow your farm fast!
Optum Medicare Support
Lesson 3 Homework Practice Measures Of Variation Answer Key
Missing 2023 Showtimes Near Landmark Cinemas Peoria
Lqse-2Hdc-D
18443168434
7 Low-Carb Foods That Fill You Up - Keto Tips
About Us | TQL Careers
Jesus Calling Oct 27
Https://Store-Kronos.kohls.com/Wfc
Walmart Double Point Days 2022
Eva Mastromatteo Erie Pa
Epro Warrant Search
Ukc Message Board
Vigoro Mulch Safe For Dogs
Concordia Apartment 34 Tarkov
Rqi.1Stop
Espn Horse Racing Results
Barber Gym Quantico Hours
Laveen Modern Dentistry And Orthodontics Laveen Village Az
1973 Coupe Comparo: HQ GTS 350 + XA Falcon GT + VH Charger E55 + Leyland Force 7V
All Breed Database
Aes Salt Lake City Showdown
Craigslist Apartments Baltimore
Craigslist List Albuquerque: Your Ultimate Guide to Buying, Selling, and Finding Everything - First Republic Craigslist
Bfsfcu Truecar
Pfcu Chestnut Street
Tire Pro Candler
Swgoh Boba Fett Counter
Word Trip Level 359
2015 Chevrolet Silverado 1500 for sale - Houston, TX - craigslist
M3Gan Showtimes Near Cinemark North Hills And Xd
Pickle Juiced 1234
Autozone Locations Near Me
Ishow Speed Dick Leak
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Torrid Rn Number Lookup
Three V Plymouth
814-747-6702
FedEx Authorized ShipCenter - Edouard Pack And Ship at Cape Coral, FL - 2301 Del Prado Blvd Ste 690 33990
The Sports Academy - 101 Glenwest Drive, Glen Carbon, Illinois 62034 - Guide
18443168434
Sml Wikia
Latest Posts
Article information

Author: Trent Wehner

Last Updated:

Views: 6461

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.