-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_and_verify_multiple.sh
executable file
·51 lines (42 loc) · 1.51 KB
/
deploy_and_verify_multiple.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Load environment variables
set -a
source .env
set +a
# Check if required environment variables are set
for var in ETHERSCAN_API_KEY RPC_URL PRIVATE_KEY; do
if [ -z "${!var}" ]; then
echo "Error: $var is not set in the .env file"
exit 1
fi
done
# Read the JSON configuration file
CONFIG_FILE="drop_config.json"
DROPS=$(cat "$CONFIG_FILE")
# Loop through each drop in the configuration
echo "$DROPS" | jq -c '.[]' | while read -r drop; do
NAME=$(echo "$drop" | jq -r '.name')
SYMBOL=$(echo "$drop" | jq -r '.symbol')
SUPPLY=$(echo "$drop" | jq -r '.supply')
BASE_URI=$(echo "$drop" | jq -r '.baseURI')
DROP_ID=$(echo "$drop" | jq -r '.dropId')
echo "Deploying and verifying contract for $NAME (Drop ID: $DROP_ID)..."
# Set environment variables for the Solidity script
export NFT_NAME="$NAME"
export NFT_SYMBOL="$SYMBOL"
export NFT_SUPPLY="$SUPPLY"
export NFT_BASE_URI="$BASE_URI"
export DROP_ID="$DROP_ID"
# Deploy and verify the contract using environment variables
COMMAND="forge script script/DeployCRNFT.s.sol:DeployCRNFT \
--rpc-url $RPC_URL \
--broadcast \
--verify \
--etherscan-api-key ${ETHERSCAN_API_KEY} \
--private-key ${PRIVATE_KEY}"
echo "Executing command: $COMMAND"
eval $COMMAND
echo "Deployment and verification process completed for $NAME (Drop ID: $DROP_ID)."
echo "----------------------------------------"
done
echo "All deployments and verifications completed."