Page partially based on OpenZeppelin Tutorial.
import@openzeppelin/contracts/access/Ownable.sol;
) can cause problems with verification. The sources must be provided explicitly during the contract verification process.
Below we describe verification information when including these contracts specific to different development environments.
Hardhat
Hardhat is a full-featured development environment for contract compilation, deployment, and verification. The Hardhat Verification plugin supports contract verification on Blockscout and includes in-built functionality to address verification with OpenZeppelin-based imports. A separate tutorial about contract verification via Hardhat on Blockscout is available here.Foundry (forge)
Foundry is a smart contract development toolchain. Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command line and via Solidity scripts. Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts. Forge supports contract verification out of the box (https://book.getfoundry.sh/reference/forge/forge-verify-contract) A separate tutorial about contract verification via Foundry on Blockscout is available here.Remix
While there are 2 plugins available to help with this process, Etherscan and Flattener. Currently only Flattener works with Blockscout. You can use this plugin to flatten contracts and submit for verification as flattened source code. This is the recommended option. We also include the Manual Standard Input JSON Method below the flattener instructions. This method is not recommended, but included since it is also a viable method.Flattener Plugin
-
Go to Plugin Manager and search for “flattener”. Activate the plugin.
-
The plugin is now available in the lefthand menu.
-
Compile the contract you want to verify.
-
Return to the Flattener. The ‘Flatten contract_name’ button should appear. Click the button. Flattened source code is copied onto the clipboard.
-
Go to Blockscout and on the verification page choose the ‘Via flattened source code’ method.
-
Paste the copied flattened source code into the ‘Enter the Solidity Contract Code’ field.
-
Check that all info is correct and click the Verify and Publish button to verify your contract. Once verified, the code tab will include the ✅ icon and source code will be viewable.
Manual Standard Input Json with Remix
Standard input json is basically the raw file fed into the Solidity compiler on verification. There are some minor updates made regarding info the output compiler should return, but the main contract-related fields remain the same. This way, standard json allows you to specify the most subtle compiler settings, as well as to specify all source files. It is quite cumbersome and tedious work, so it is preferable to use any of the above methods, however, we describe the process in more detail for those who want to use it. For this tutorial, we will create standard json for the following contract:
OpenZeppelinSample.sol
file
.deps/npm/
directories, which will appear after contract compilation.

../utils/Context.sol
” imported from @openzeppelin/contracts/access/Ownable.sol
. You can find it in the same .deps/npm
directory.

Although import ”../utils/Context.sol”; specifies a relative path, the absolute path is used in standard json, and can be found relative to @openzeppelin/contracts/access/Ownable.sol
