This page uses machine translation from English, which may contain errors or unclear language. For the most accurate information, please see the original English version. Some content may be in the original English due to frequent updates. Help us improve this page's translation by joining our effort on Crowdin. (Crowdin translation page, Contributing guide)
How to Verify Smart Contracts Using Sourcify
Sourcify is a Solidity (smart contracts) source code verification service for Ethereum and EVM-compatible chains like Kaia. One of its unique features is that it leverages the Solidity metadata file to "fully verify" the contracts.
In this guide, we'll take a look at how to verify a smart contract on Foundry using Sourcify.
Getting started
This guide expects that you have an idea of developing smart contracts with Foundry. See Deploy smart contract using Foundry to get started. Foundry provides native support for Sourcify verification—all you need to do is add a few flags to your forge command. To verify contracts with Sourcify using Foundry, see the steps below:
Deploy and verify a contract:
/* deploy */forge create --rpc-url $KAIROS_RPC_URL --private-key $PRIVATE_KEY src/Counter.sol:Counter --broadcast
//* verify an already deployed contract as seen above *//forge verify-contract 0x2a31C3f597d8FD0Fbc5Ff02439ce6c6aEFb680a2 src/Counter.sol:Counter --chain-id 1001 --verifier sourcify --verifier-url https://sourcify.dev/server/
You can look up the verified contract here
Check if a contract is verified
forge verify-check 0x2a31C3f597d8FD0Fbc5Ff02439ce6c6aEFb680a2 --chain-id 1001 --verifier sourcify