How to Verify Contracts
Using the UI (legacy)
- Drag and drop the folder containing your source files and metadata, or add them seperately.
- Input the contract address you want to verify.
- Select the chain the contract is deployed to.
- Click "Verify".
Foundry
Foundry natively supports Sourcify verification. You can verify contracts with the additional verify flags in Forge:
Deploy and verify a contract:
forge create --rpc-url <your_rpc_url> \
--constructor-args "ForgeUSD" "FUSD" 18 1000000000000000000000 \
--private-key <your_private_key> \
src/MyToken.sol:MyToken \
--verify \
--verification-provider sourcify
forge verify-contract 0x55f7d4279CE387067f12561e7E0c194f5186cFba \
src/MyToken.sol:MyToken \
--chain-id 11155111 \
--verifier sourcify
forge verify-check 0x55f7d4279CE387067f12561e7E0c194f5186cFba \
--chain-id 11155111 \
--verifier sourcify
Hardhat
hardhat-deploy plugin
The Hardhat plugin @wighawag/hardhat-deploy has Sourcify support. After deploying your contracts with the plugin you can easily verify your contracts with:
hardhat --network mainnet sourcify
hardhat-sourcify plugin
The plugin @xtools-at/hardhat-sourcify can verify any contract deployed with Hardhat. After adding the plugin to your hardhat.config file, you can verify your contracts using:
hardhat --network mainnet verify-sourcify --contract "MyContract" --address 0x12345...
With Hardhat output
Sourcify can parse the Hardhat .json
output file under artifacts/build-info
to verify contracts.
info
Only after Hardhat version v2.6.8 the metadata files were output by default. If you are using an earlier version, you need to add the metadata to compilation outputs manually as described here
- Drag and drop the
.json
file at sourcify.dev. - Select the main contract deployed at the address you want to verify.
- Input the address and chain and click "Verify".
Truffle
If you were using Truffle to compile contracts, you can use the output file at build/contracts/<contract-name>.json
for the metadata file. Then add the source files as usual.
truffle-verify-plugin
If you've deployed your contracts with Truffle, you can use the truffle-plugin-verify to verify contracts on Sourcify. The plugin verifies on Sourcify by default.
$ truffle run verify MyFirstContract MySecondContract --network goerli
Remix Plugin
Sourcify has a remix plugin to aid with contract verification and lookup. The plugin can be found in this repository https://github.com/sourcifyeth/remix-sourcify
Verifying
To verify:
- Select the contract you want to verify in the file explorer
- Compile the contract
- Click on the Sourcify icon on the plugin manager
- Enter the chain and the address of the contract you want to verify
- Click on Verify
Fetching
You can also "fetch" contracts that are verified on Sourcify into your Remix IDE. To fetch:
- Click on the Sourcify icon on the plugin manager
- Enter the chain and the address of the contract you want to fetch
- Click on Fetch
The contract files will be saved in the file explorer.
Installation
- Navigate to the Remix Plugin manager
- Search for
Sourcify
and click on Activate when you see it. - Another option would be to click on the Sourcify logo on Remix Homepage to activate the plugin