3.7.2. ChainIDE Etherscan Verifier
ChainIDE offers contract verification plug-ins that can scan and verify smart contracts on various major public chains, such as Ethereum, Polygon, Conflux, and BNB Chain.
An Etherscan verifier is used to verify a smart contract. But you might be curious about why we need to verify the smart contract. So, here's why.
Verifying a smart contract on Etherscan is important for several reasons:
- 1.Ensuring accuracy: Verifying a smart contract on Etherscan ensures that the contract code that is published on the Ethereum blockchain is the same as the original code that was used to create the contract. This helps prevent errors or malicious code from being introduced into the contract.
- 2.Building trust: By verifying a smart contract on Etherscan, developers and users can be confident that the contract is legitimate and not a scam. This builds trust and confidence in the contract and the parties involved.
- 3.Facilitating audits: Verifying a smart contract on Etherscan also facilitates audits by third-party security experts who can review the code and provide feedback on any vulnerabilities or issues that need to be addressed.
- 4.Improving transparency: Verifying a smart contract on Etherscan increases transparency by making the contract code visible to anyone who wants to see it. This helps ensure that the contract operates as intended and provides the expected outcomes.
- 5.Interaction through scan: Once a smart contract is verified on Etherscan, users can interact with it directly through the Etherscan website. This allows users to view and interact with the smart contract's functions and data without the need for a separate user interface or application.
The above-mentioned are some of the reasons why we need to verify a smart contract. Let's move on forward and see how to verify a smart contract.
Once a smart contract is deployed, its source code can be uploaded and authenticated using an Etherscan verifier. This tutorial aims to showcase the process of utilizing an Etherscan verifier for uploading and verifying the source code of an Ethereum contract after it has been deployed. For this tutorial, we will be using an Etherscan API KEY since we are using Etherscan. However, if you intend to use other scans like BNB scan or Polygon scan, you will need to obtain the API KEY from the corresponding public chain's scan. The procedure is divided into three steps:
- 1.Go to Etherscan to register an account and obtain an API key.
- 2.Enter ChainIDE and select the verification plug-in panel.
- 3.Fill in the necessary parameters for the contract verification.
Visit the Etherscan API key panel here: https://etherscan.io/myapikey, and create an account if you don't have one already. After creating an account, log in to your account, and go to the "API Keys" section under the "OTHERS". Click the "+Add" button in front of the "My API Keys" and a new panel will be popped up; write down your project name there and press the "Create New API Key" button, and now you'll get a new API Key Token.
Go to ChainIDE. Choose a smart contract that you want to get verified, compile and deploy the smart contract. After deployment, open the "Etherscan Verifier" and fill in all the required information. The details of each required field are given below:
- 1.API End Point: The API URL provided by Etherscan will be automatically filled in when connecting to a specific network. For example, the link in the figure is the Goerli Testnet of Ethereum.
- 2.API Key: The API Key obtained in the previous step; you need to bring this address to access the URL of Etherscan.
- 3.Remember the API Key: this will record the API in local storage.
- 4.Compiled Contract: Select among the compiled contracts the one that needs to be verified.
- 5.Contract Address: Fill in the address of the deployed smart contract.
- 6.Constructor Parameters: Fill in the deployment parameters.
After filling in all the above information, click the "Verify" button.
After clicking the "Verify" button, if everything is correct, your contract will be verified, and a link to view your verified smart contract on the Etherscan will be given.