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
The Start of De-Dollarization: China’s Move Away From the USD | OilPrice.com
Why We Self-Sabotage and How To Stop the Cycle
Pixel Speedrun Unblocked 76
Jennifer Hart Facebook
Teenbeautyfitness
David Packouz Girlfriend
Painting Jobs Craigslist
Magic Mike's Last Dance Showtimes Near Marcus Cedar Creek Cinema
iOS 18 Hadir, Tapi Mana Fitur AI Apple?
Lesson 8 Skills Practice Solve Two-Step Inequalities Answer Key
Love In The Air Ep 9 Eng Sub Dailymotion
Amc Flight Schedule
Niche Crime Rate
Race Karts For Sale Near Me
China’s UberEats - Meituan Dianping, Abandons Bike Sharing And Ride Hailing - Digital Crew
Our History
Project, Time & Expense Tracking Software for Business
Reptile Expo Fayetteville Nc
Hannah Palmer Listal
A Christmas Horse - Alison Senxation
Tinyzonehd
Truck from Finland, used truck for sale from Finland
Pokemon Inflamed Red Cheats
Jazz Total Detox Reviews 2022
Pioneer Library Overdrive
Mchoul Funeral Home Of Fishkill Inc. Services
Stouffville Tribune (Stouffville, ON), March 27, 1947, p. 1
The Bold and the Beautiful
Street Fighter 6 Nexus
Craigs List Tallahassee
Boondock Eddie's Menu
Indiana Immediate Care.webpay.md
Sinai Sdn 2023
Greater Keene Men's Softball
Ukg Dimensions Urmc
Hannibal Mo Craigslist Pets
Poe Flameblast
Temu Y2K
Www Craigslist Com Brooklyn
The All-New MyUMobile App - Support | U Mobile
Sas Majors
Gopher Hockey Forum
✨ Flysheet for Alpha Wall Tent, Guy Ropes, D-Ring, Metal Runner & Stakes Included for Hunting, Family Camping & Outdoor Activities (12'x14', PE) — 🛍️ The Retail Market
Tito Jackson, member of beloved pop group the Jackson 5, dies at 70
300+ Unique Hair Salon Names 2024
99 Fishing Guide
Ark Silica Pearls Gfi
Competitive Comparison
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.