1+ #! /bin/bash
2+
3+ # Contract verification script for Monad network
4+ # Usage: bash verifyContract.sh <contract_address> <source_file:contract_name> [constructor_args] [api_key]
5+ # Example: bash verifyContract.sh 0x4F826CDf1eac05d05aEC62EDC87EE3753e9440b5 src/CampaignFactory.sol:CampaignFactory $(cast abi-encode "constructor(address,address)" 0x66661860a6C83c51C4F6eFAb07E3E80Eb194514D 0x25daAde2d1B6a36A7f551C971B76964Bc0a49504) your_api_key
6+
7+ if [ $# -lt 2 ] || [ $# -gt 4 ]; then
8+ echo " Wrong argument count"
9+ echo " Usage: bash verifyContract.sh <contract_address> <source_file:contract_name> [constructor_args] [api_key]"
10+ echo " Note: If api_key is not provided, ETHERSCAN_API_KEY environment variable will be used"
11+ exit 1
12+ fi
13+
14+ CONTRACT_ADDRESS=" $1 "
15+ SOURCE_FILE=" $2 "
16+ CONSTRUCTOR_ARGS=" $3 "
17+ API_KEY=" $4 "
18+
19+ # Use provided API key or fall back to environment variable
20+ if [ -n " $API_KEY " ]; then
21+ ETHERSCAN_API_KEY=" $API_KEY "
22+ elif [ -z " $ETHERSCAN_API_KEY " ]; then
23+ echo " Error: No API key provided. Either pass it as 4th argument or set ETHERSCAN_API_KEY environment variable"
24+ exit 1
25+ fi
26+
27+ # Build the base arguments
28+ BASE_ARGS=" $CONTRACT_ADDRESS $SOURCE_FILE "
29+
30+ # Add constructor args if provided
31+ if [ -n " $CONSTRUCTOR_ARGS " ]; then
32+ ADDITIONAL_ARGS=" --constructor-args $CONSTRUCTOR_ARGS $BASE_ARGS "
33+ else
34+ ADDITIONAL_ARGS=" $BASE_ARGS "
35+ fi
36+
37+ echo " Verifying contract with args: $ADDITIONAL_ARGS "
38+
39+ echo " Verifying on Etherscan..."
40+ forge verify-contract \
41+ --watch \
42+ --etherscan-api-key $ETHERSCAN_API_KEY \
43+ --verifier-url " https://api.etherscan.io/api?chainid=10143" \
44+ --chain-id 10143 \
45+ $ADDITIONAL_ARGS
46+
47+ echo " Verifying on Monad Explorer..."
48+ forge verify-contract \
49+ --watch \
50+ --verifier sourcify \
51+ --verifier-url ' https://sourcify-api-monad.blockvision.org' \
52+ --chain-id 10143 \
53+ $ADDITIONAL_ARGS
54+
55+ echo " Verifying on Socialscan..."
56+ forge verify-contract \
57+ --watch \
58+ --verifier etherscan \
59+ --verifier-url ' https://api.socialscan.io/monad-testnet/v1/explorer/command_api/contract' \
60+ --etherscan-api-key $ETHERSCAN_API_KEY \
61+ --chain 10143 \
62+ $ADDITIONAL_ARGS
0 commit comments