Sourcify Plugin
Sourcify Plugin for Hardhat
Similar to the hardhat verification plugin, this plugin submits the contract source and other info of all deployed contracts to Sourcify.
1) Tune Hardhat environment. For seamless usage, you should setup your environment following this tutorial (note, it will take an hour or so to run through). In this example we setup to use the Sokol test network. See the Hardhat Verification Tutorial for more information on the config file setup.
2) Deploy contract. More deployment details here. Note that we run from node_modules.bin\hardhat
to circumvent package.json warning and use --network sokol
to specify the network.
3) Verify contract.
4) Confirm verification in BlockScout. Go to your BlockScout instance and paste the contract address into the search bar. If verified, the code tab will display a green checkmark.
Selecting the Code tab will show additional information about your contract.
Contract Verification via Sourcify
Along with contract verification through a flattened source file (the default option in Blockscout), a Sourcify API verification option is also available. The Verification with Sourcify feature is enabled in the xDai instance of Blockscout and available in version 3.7.0+. Projects who want to use this feature need to set the following ENV variables.
Usage Example
Verify your contract using Sourcify:
Open the address page for the contract you want to verify, switch to Code tab, and click Verify & Publish button.
Choose Sources and metadata JSON file option and click the Next button.
On the next screen, you will see a drop field where you will add files.
Drag and drop (or click the button to add files from your computer) all .sol files used by the target contract you want to verify and the .json file containing the contract's metadata. For example, this .json is created by Truffle in ./build/contracts folder after
truffle compile
. If your contract has linked libraries you should also drag & drop .json files _for those libraries. Once all files are added, start verification by clicking the _Verify & Publish button.
After several seconds your contract should be verified through Sourcify's API (If verification fails, you will see the reason in the dropzone). Verification metadata will be saved in the Blockscout DB and you will see the verified contract page with the link to the same metadata in the Sourcify contract repository (chain ID is 100 for the xDai chain).
Example Contract:
The same contract in the Sourcify contract repository.
Last updated