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
Introduction to funds | Barclays Smart Investor
eToro vs Binance: Which One Is Better To Use? - doola: Start your dream US business and keep it 100% compliant
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
What to Do For Dog Upset Stomach
Pga Scores Cbs
Summit County Juvenile Court
Mr Tire Rockland Maine
Whiskeytown Camera
Corporate Homepage | Publix Super Markets
Blue Ridge Now Mugshots Hendersonville Nc
Mens Standard 7 Inch Printed Chappy Swim Trunks, Sardines Peachy
978-0137606801
Eka Vore Portal
Tvtv.us Duluth Mn
Craigslist In Flagstaff
Ups Access Point Lockers
Classic | Cyclone RakeAmerica's #1 Lawn and Leaf Vacuum
Plan Z - Nazi Shipbuilding Plans
Watch The Lovely Bones Online Free 123Movies
How To Level Up Roc Rlcraft
Google Doodle Baseball 76
Lakers Game Summary
Qhc Learning
Inbanithi Age
Sister Souljah Net Worth
Account Now Login In
Great ATV Riding Tips for Beginners
3 Ways to Drive Employee Engagement with Recognition Programs | UKG
Dhs Clio Rd Flint Mi Phone Number
Craigslist Efficiency For Rent Hialeah
Tire Pro Candler
Urban Blight Crossword Clue
Soiza Grass
Fox And Friends Mega Morning Deals July 2022
Tendermeetup Login
Ni Hao Kai Lan Rule 34
Orangetheory Northville Michigan
Ippa 番号
Rogers Centre is getting a $300M reno. Here's what the Blue Jays ballpark will look like | CBC News
Easy Pigs in a Blanket Recipe - Emmandi's Kitchen
10 Rarest and Most Valuable Milk Glass Pieces: Value Guide
Other Places to Get Your Steps - Walk Cabarrus
Subdomain Finder
Vintage Stock Edmond Ok
My Eschedule Greatpeople Me
Workday Latech Edu
Mail2World Sign Up
Latina Webcam Lesbian
Product Test Drive: Garnier BB Cream vs. Garnier BB Cream For Combo/Oily Skin
Diamond Desires Nyc
Lorcin 380 10 Round Clip
Att Corporate Store Location
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.