@@ -39,6 +39,10 @@ if ! command -v forge >/dev/null 2>&1; then
3939 echo " forge is required" >&2
4040 exit 1
4141fi
42+ if ! command -v curl > /dev/null 2>&1 ; then
43+ echo " curl is required" >&2
44+ exit 1
45+ fi
4246
4347if [[ $# -lt 1 ]]; then
4448 echo " Usage: scripts/verify-from-json.sh <path-to-l1-verify.json> [--chain <id|name>] [--api-key <key>]" >&2
@@ -78,6 +82,21 @@ if [[ -z "$API_KEY_VALUE" ]]; then
7882 exit 1
7983fi
8084
85+ # Sourcify server (can override via $SOURCIFY_SERVER_URL)
86+ SOURCIFY_SERVER_URL=" ${SOURCIFY_SERVER_URL:- https:// sourcify.dev/ server} "
87+
88+ # Import a verified contract from Etherscan into Sourcify v2
89+ sourcify_import () {
90+ local address=" $1 "
91+ local chain_id=" $CHAIN_VALUE "
92+ local endpoint=" $SOURCIFY_SERVER_URL /v2/verify/etherscan/$chain_id /$address "
93+ local payload
94+ # Only etherscanApiKey is required in body for this endpoint
95+ payload=$( jq -n --arg key " $API_KEY_VALUE " ' {apiKey:$key}' )
96+ echo " Importing to Sourcify: $address (chain $chain_id )"
97+ curl -sS -X POST -H ' Content-Type: application/json' -d " $payload " " $endpoint " | sed ' s/^/ sourcify: /'
98+ }
99+
81100# Map deployment "name" to FQN "<path>:<ContractName>"
82101resolve_fqn () {
83102 local name=" $1 "
@@ -147,8 +166,9 @@ if [[ ${#__all_libs[@]} -gt 0 ]]; then
147166 --chain " $CHAIN_VALUE " \
148167 --etherscan-api-key " $API_KEY_VALUE " \
149168 " $address " " $file :$contract " \
150- --compiler-version v0.8.27 \
151- --verifier sourcify
169+ --compiler-version v0.8.27
170+
171+ sourcify_import " $address "
152172 fi
153173 done
154174fi
@@ -180,6 +200,7 @@ for i in $(seq 0 $((records_len - 1))); do
180200 echo " Command: ${cmd[*]} "
181201
182202 " ${cmd[@]} "
203+ sourcify_import " $addr "
183204done
184205
185206echo " All verification commands executed."
0 commit comments