Verify Smart Contract
In this section, we will go over the process of verifying a smart contract in Subscan. Verifying your smart contract allows for readable and interpretable data (such as function calls and parameters) to be displayed directly in Subscan, making it easier to understand and debug interactions with the contract.
Prerequisites
- Familiar with Subscan Block Explorers. If not checkout the Block Explorers section.
- You have previously deployed a smart contract using one of the previous tutorials (e.g.
SimpleStorage.sol
).
Instructions
Follow these steps to complete the verification process. We will be showing how this ca:
1. Go to Remix for content
We will be using the same Remix IDE workspace that was used to deploy the SimpleStorage.sol
contract.
Once you are there:
- Open up the
artifacts/build-info/hex_value
file. This contains the content we need to move to theSimpleStorage_metadata.json
file. - Copy and paste the entire
content
line as shown in the screenshot above.
2. Paste content into SimpleStorage_metadata
After copying this content we will need to paste it into the SimpleStorage_metadata.json
file.
- Navigate to the
SimpleStorage_metadata.json
file. - Find the
sources
object where the data for contractSimpleStorage.sol
is stored. - Paste the content after the
license
field.
3. Download the SimpleStorage_metadata.json file
The next step is to simply download this file to your local machine. It will be used later in the verification process.
4. Navigate to Subscan
Now go to Subscan and search for your deployed contract address. Then go to the Contract
tab.
5. Verify Contract
- Confirm the
Contract Address
field matched your Smart Contract to verify. - Select Solidity (Standard-JSON-Input) as
Compiler Type
. - Pick whether or not you would like to
Include Nightly Builds
. - Choose the
Compiler Version
that was used when you compiled your smart contract. - Upload the file that we downloaded from Remix earlier.
- Finally, click the
Verify & Publish
button.
6. Confirm Verification
A proper Contract Verification will have a ✅ next to Contract.
Contract Information Displayed
- Contract Name:
SimpleStorage
- Compiler Version:
v0.8.26+commit.8a97fa7a
- EVM Version:
cancun
- Optimization:
false
This indicates the deployed contract was compiled using Solidity version 0.8.26
, with the Ethereum Virtual Machine (EVM) set to cancun
, and without optimization enabled.
Contract ABI
- The ABI (Application Binary Interface) specifies the interface of the contract.
- It includes the function details such as:
- Function
get
:- Inputs: None.
- Outputs: A single
uint256
value. - Mutability:
view
(read-only).
- Function
set
:- Inputs: A single
uint256
value (_data
). - Outputs: None.
- Mutability:
nonpayable
(modifies the state).
- Inputs: A single
- Function
This confirms the contract has two primary functions:
set(uint256 _data)
: Stores a value.get()
: Retrieves the stored value.
Contract Source Code
The source code of the contract is displayed as it was written:
- Logic:
set
: Allows the user to save auint256
value in the contract’s state.get
: Returns the saved value without modifying the state.
Contract Bytecode
- The bytecode is the compiled version of the Solidity source code.
- It is what gets deployed to the Ethereum blockchain.
- This bytecode matches the source code provided in the screenshot.
Summary
By completing the process, your contract will be displayed with all relevant details, as seen in the successful verification example above. This ensures a professional and polished deployment on the blockchain.