Verifying your Smart Contract
In order for your deployed smart contract(s) to be human-readable on block explorers like Blockscout they must be verified. Verification is highly recommended to increase trust in your code and dapp.
Smart contracts can be verified through the Blockscout UI or a host of other methods.
Verifying a Smart Contract using the Blockscout UI
Verification is available for both Solidity and Vyper contracts. Currently, there are 7 different types of inputs you can use for verification using the Blockscout UI.
👷🏻♂️ If preferred you can verify directly from your Hardhat or Foundry dev environment.
Smart Contract Verification with Blockscout
- Go to the Verify contract page (Other -> Verify contract)
- Enter in the contract address you received during deployment. The dropdown will show you several available verification options. Select the one you would like to use and continue.
Input Types
Choose the format that applies to your files:
-
Solidity (Flattened source code)
-
Solidity (Standard JSON input)
-
Solidity (Sourcify)
-
Solidity (Multi-part files)
-
Vyper (Contract)
-
Vyper (Multi-part files)
-
Vyper (Standard JSON input)
Solidity (Flattened source code)
This verification method is recommended only for single-file smart contract without any imports. For verification of contracts containing more that 1 file, it's recommended to use different verification method.
-
Contract Address: The
0x
address supplied on contract creation (added above) -
Is Yul contract: Select if the contract is coded in Yul for efficiency.
-
Include Nightly Builds: Select if you want to show nightly builds.
-
Compiler: derived from the first line in the contract
pragma solidity X.X.X
. Use the corresponding compiler version rather than the nightly build. -
EVM Version: Select the correct EVM version if known, otherwise use default.
-
Optimization Enabled: If you enabled optimization during compilation, select and enter the run value. 200 is the Solidity Compiler default value. Only change if you changed this value while compiling.
-
Enter the Solidity Contract Code: Copy-paste the source code of your smart contract as is.
-
Add Contract Libraries: Enter the name and 0x address for any required libraries called in the .sol file. You can add multiple contracts with the "+" button.
-
Click the
Verify and Publish
button. -
If all goes well, you will see a checkmark ✅ next to Code in the code tab, and an additional tab called
Read Contract
. The contract name will now appear in BlockScout with any transactions related to your contract.
Solidity (Standard JSON input)
More information on JSON input is available here.
-
Include nightly builds. You can choose
Yes
orNo
depending on your compiler. -
Compiler. Choose the compiler version used to compile your smart contract. If you selected yes for nightly builds, use the compiler version rather than the build.
-
Standard Input JSON. Upload your Standard Input JSON file. File should follows solidity format and all the sources must be in Literal Content format, not a URL.
Click the Verify & publish
button and wait for the response.
Via Sourcify: Sources and metadata JSON file
See Contract Verification via Sourcify for details.
Solidity (Multi-part files)
See the above settings. You will upload all of the .sol or .yul files you used for your contract. This method requires at least 2 files - if you have a single file use the flattened source code method.
Vyper Contract
Contract Name: Name assigned to the contract.
-
Compiler: Select the compiler version used in the source code.
-
EVM Version: Select the correct EVM version if known, otherwise use default.
-
Contract Code: Copy and paste the contract code
-
Click the
Verify and Publish
button.
If all goes well, you will see a checkmark ✅ next to Code in the code tab, and an additional tab called Read Contract
. The contract name will now appear in BlockScout with any transactions related to your contract.
Vyper Multi-part files and standard json input
See the information above.
Troubleshooting
If you receive the dreaded There was an error compiling your contract
message this means the bytecode doesn't match the supplied sourcecode. Unfortunately, there are many reasons this may be the case. Here are a few things to try:
- Double check the compiler version is correct.
Check all version digits - for example 0.5.1 is different from 0.5.10
-
Check that an extra space has not been added to the end of the contract. When pasting in, an extra space may be added. Delete this and attempt to recompile.
-
Copy, paste, and verify your source code in Remix. You may find some exceptions here.
Verification in a dev environment The Hardhat verification plugin supports BlockScout. You can also choose to use the Sourcify plugin to verify with Sourcify from your hardhat environment. Foundry supports blockscout verification with Forge.