-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add simple scripts for verifying contracts on etherscan(s)
- Loading branch information
1 parent
669eb6b
commit 4bae93c
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
################################################################################ | ||
# Verifies a contract across multiple chains | ||
# - Requires the contract to be at the same address on every chain | ||
# - Requires the appropriate API keys to be set in .env | ||
################################################################################ | ||
|
||
# Example usage: | ||
# CONTRACT=DelegationManager | ||
# ADDRESS=0x0000000000000000000000000000000000000000 | ||
# CONSTRUCTOR="constructor(string,string,uint256,uint256)" "ForgeUSD" "FUSD" 18 1000000000000000000000 | ||
|
||
CONTRACT=NativeTokenPaymentEnforcer | ||
ADDRESS=0x87Fe18EbF99e42fcE8A03a25F1d20E119407f8e7 | ||
CONSTRUCTOR_ARGS=$(cast abi-encode "constructor(address, address)" "0x56D56e07e3d6Ee5a24e30203A37a0a460f42D7A3" "0x7378dE585998d3E18Ce147867C335C25B3dB8Ee5") | ||
|
||
# sepolia, linea-sepolia, linea, base, optimism, arbitrum, polygon | ||
CHAIN_IDS=(11155111 59141 59144 8453 10 42161 137) | ||
|
||
set -o allexport | ||
source .env | ||
set +o allexport | ||
|
||
# Function to get the appropriate API key based on chain ID | ||
get_api_key() { | ||
case $1 in | ||
11155111) echo "$ETHERSCAN_API_KEY" ;; | ||
59144) echo "$LINEASCAN_API_KEY" ;; | ||
59141) echo "$LINEASCAN_API_KEY" ;; | ||
8453) echo "$BASESCAN_API_KEY" ;; | ||
10) echo "$OPTIMISTIC_ETHERSCAN_API_KEY" ;; | ||
42161) echo "$ARBISCAN_API_KEY" ;; | ||
137) echo "$POLYGONSCAN_API_KEY" ;; | ||
*) echo "Unknown chain ID" && return 1 ;; | ||
esac | ||
} | ||
|
||
for CHAIN_ID in "${CHAIN_IDS[@]}" | ||
do | ||
API_KEY=$(get_api_key $CHAIN_ID) | ||
|
||
echo "Verifying $CONTRACT at $ADDRESS on $CHAIN_ID..." | ||
|
||
forge verify-contract \ | ||
--chain-id $CHAIN_ID \ | ||
--num-of-optimizations 200 \ | ||
--watch \ | ||
--constructor-args $CONSTRUCTOR_ARGS \ | ||
--etherscan-api-key $API_KEY \ | ||
$ADDRESS \ | ||
src/enforcers/$CONTRACT.sol:$CONTRACT | ||
|
||
echo "Verification of $CONTRACT on $CHAIN_ID completed." | ||
echo "-------------------------------------------" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
################################################################################ | ||
# Verifies contracts across multiple chains | ||
# - Requires contracts to be at the same address on every chain | ||
# - Requires the appropriate API keys to be set in .env | ||
# - Requires the contracts to have no constructor arguments | ||
################################################################################ | ||
|
||
# Note: Array lengths must line up | ||
ENFORCERS=() | ||
ADDRESSES=() | ||
|
||
# sepolia, linea-sepolia, linea, base, optimism, arbitrum, polygon | ||
CHAIN_IDS=(11155111 59141 59144 8453 10 42161 137) | ||
|
||
set -o allexport | ||
source .env | ||
set +o allexport | ||
|
||
# Function to get the appropriate API key based on chain ID | ||
get_api_key() { | ||
case $1 in | ||
11155111) echo "$ETHERSCAN_API_KEY" ;; | ||
59144) echo "$LINEASCAN_API_KEY" ;; | ||
59141) echo "$LINEASCAN_API_KEY" ;; | ||
8453) echo "$BASESCAN_API_KEY" ;; | ||
10) echo "$OPTIMISTIC_ETHERSCAN_API_KEY" ;; | ||
42161) echo "$ARBISCAN_API_KEY" ;; | ||
137) echo "$POLYGONSCAN_API_KEY" ;; | ||
*) echo "Unknown chain ID" && return 1 ;; | ||
esac | ||
} | ||
for ((i=0; i<${#ENFORCERS[@]}; i++)); do | ||
echo "Iteration $i" | ||
echo "-------------------------------------------" | ||
|
||
CONTRACT=${ENFORCERS[i]} | ||
ADDRESS=${ADDRESSES[i]} | ||
|
||
for CHAIN_ID in "${CHAIN_IDS[@]}" | ||
do | ||
API_KEY=$(get_api_key $CHAIN_ID) | ||
|
||
echo "Verifying $CONTRACT at $ADDRESS on $CHAIN_ID..." | ||
|
||
forge verify-contract \ | ||
--chain-id $CHAIN_ID \ | ||
--num-of-optimizations 200 \ | ||
--watch \ | ||
--etherscan-api-key $API_KEY \ | ||
$ADDRESS \ | ||
src/enforcers/$CONTRACT.sol:$CONTRACT | ||
|
||
echo "Verification of $CONTRACT on $CHAIN_ID completed." | ||
echo "-------------------------------------------" | ||
done | ||
done |