Last active
June 19, 2024 11:22
-
-
Save riordant/6c65d80012f580efc866bedaf03b07a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
# takes in a deployment file and verifies on etherscan/arbitrum/etc. | |
# useful if you deploy without verification, or verification fails | |
# needs to have ETHERSCAN_API_KEY set in the environment | |
# execute like so: sh ./verify_after_deploy_foundry.sh ./broadcast/<SCRIPT_NAME>.sol/<CHAIN_ID>/run-latest.json | |
set -e | |
set -o xtrace | |
INPUT_FILE=$1 | |
ARG_FILE="$(dirname $INPUT_FILE)/arguments.json" | |
CHAIN_ID=$(jq -r '.chain' < $INPUT_FILE) | |
COMPILER_VERSION="0.8.17" | |
LIBRARIES="" | |
for row in $(jq -c '.libraries[]' < ${INPUT_FILE}); do | |
LIBRARIES+=" --libraries ${row}" | |
done | |
LIBRARIES=$( echo $LIBRARIES | tr -d '"' | tr -d "'" ) | |
for row in $(jq -c '.transactions[]' < ${INPUT_FILE}); do | |
_jq() { | |
echo ${row} | jq -r ${1} | |
} | |
if [[ $(_jq '.transactionType') == "CREATE" ]]; then | |
args=$(_jq '.arguments') | |
CONSTRUCTOR_ARGS_PATH="" | |
if [[ ${args} != "null" ]]; then | |
echo ${args} > "${ARG_FILE}" | |
CONSTRUCTOR_ARGS_PATH=--constructor-args-path=${ARG_FILE} | |
fi | |
if ! forge verify-contract "$(_jq '.contractAddress')" "$(_jq '.contractName')" --etherscan-api-key ${ETHERSCAN_API_KEY} --chain ${CHAIN_ID} --compiler-version ${COMPILER_VERSION} ${CONSTRUCTOR_ARGS_PATH} {$LIBRARIES} | |
then | |
echo "failed to verify $(_jq '.contractName')" | |
continue | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment