PhronScan
Verify Smart Contracts using PhronScan
Introduction
Verifying smart contracts on a PhronScan is a great way to improve the transparency and security of deployed smart contracts on Phron. Users can directly view the source code for verified smart contracts, and for some block explorers, they can also directly interact with the contract's public methods through the PhronScan's interface.
This page will outline the steps for verifying smart contracts on Phron networks through block explorers.
Deploying the Contract
In order to verify a smart contract on a PhronScan, the contract must first be deployed on the target network. This tutorial will be about deploying the smart contract to Phron.
You can check out this page for a tutorial on deploying smart contracts using Ethereum libraries on Phron. You may also use a developer tool such as Remix, Hardhat, or another tool if preferred, to deploy the smart contract to Phron.
This tutorial will use the same contract as the above deployment tutorial for the contract verification example.
The contract used is a simple incrementer, arbitrarily named Incrementer.sol
. The Solidity code is the following:
Collecting Information for Contract Verification
You will need to collect some information related to the contract's compiler and deployment in order to verify it successfully.
Take note of the Solidity compiler version used to compile and deploy the contract. The Solidity compiler version can usually be selected or specified in the deployment tool used
Take note of any SPDX license identifier used at the beginning of the Solidity source file (this example uses an MIT license):
(Optional) If optimization is enabled during compilation, take note of the value of the optimization runs parameter
(Optional) If the contract constructor method accepts arguments, take note of the ABI-encoded form of the constructor arguments
After deployment, take note of the deployed contract address of the smart contract. The deployment address of the contract can be found either in the console output if using a command-line-based tool such as Hardhat, or an Ethereum library, or it can be copied from the GUI in tools such as Remix IDE
Verify the Contract
The next step will be verifying the smart contract in an EVM-compatible explorer for the Phron network that you deployed to.
Phronscan
Take the following steps to verify the contract on Phronscan:
Go to the PhronScan.
Fill in the contract's deployed address in the first field, including the
0x
prefix
Click on contract tab
Then click on Verify & publish
Select the compiler type. For the current
Incrementer.sol
example, select Solidity (Single file)After selecting the compiler type, select the compiler version used to compile the contract. If the compiler version used was a nightly commit, uncheck the box under the field to select the nightly version
Select the open-source license used. For the current
Incrementer.sol
example, select the option MIT License (MIT). If there was none used, select No License (None)Copy and paste the entirety of the contract's content into the text field labeled as such
(Optional) Select Yes for Optimization if it was enabled during compilation, and fill in the number of runs under Misc Settings/Runs(Optimizer)
(Optional) Add contract libraries and their addresses, if any were used in the contract
(Optional) Check any other optional fields that may apply to your contract, and fill them out accordingly
After a short wait, the result of verification will be displayed in the browser, and a success result page will display the contract's ABI-encoded constructor arguments, the contract name, bytecode, and ABI.
Smart Contract Flattening
For verifying smart contracts that are made up of multiple files, the process is slightly different and requires some pre-processing to combine all the dependencies of the target smart contract into a single Solidity file.
This pre-processing is usually referred to as smart contract flattening. There are a number of tools that can be used to flatten a multi-part smart contract into a single Solidity file, such as Hardhat's Flatten task. Please refer to the respective smart contract flattening tool's documentation for more detailed instructions on its usage.
After flattening the multi-part smart contract, it can be verified using the new flattened Solidity file on a PhronScan in the same way that a single-file smart contract is verified, as described in this tutorial.
Last updated