Verify using Foundry
Verifying a smart contract on the blockchain is an essential step to ensure its transparency, security and ease of interaction for users and other developers.
This project is a demonstration of how to verify a contract on blockscout using foundry.
1. Clone repository
git clone https://github.com/alt-research/contract-verify-sample.git
2. Navigate to foundry
folder
cd foundry
3. Install dependencies
forge install
4. Deploy sample contract
forge create --rpc-url <L2 RPC URL> --private-key <Your Private Key> src/Counter.sol:Counter
// deploy address = 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
5. Verify sample contract
forge verify-contract --verifier blockscout --verifier-url <L2 Verifier URL > --chain-id <Chain ID> <Contract Address> src/Counter.sol:Counter
The output looks like below:
Start verifying contract `0x5FC8d32690cc91D4c39d9d3abcBD16989F875707` deployed on 1637450
Submitting verification for [src/Counter.sol:Counter] 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707.
Submitted contract for verification:
Response: `OK`
GUID: `5fc8d32690cc91d4c39d9d3abcbd16989f875707661fa406`
6. Confirm verification
After executing the relevant command, visit the Xterio explorer (Mainnet / Testnet) to see your contract's status.