-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathdeploy.sh
More file actions
61 lines (48 loc) · 2.11 KB
/
deploy.sh
File metadata and controls
61 lines (48 loc) · 2.11 KB
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
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Exit on error
set -e
# Default values for network and account
NETWORK=${1:-${NETWORK:-"testnet"}}
ACCOUNT=${SOROBAN_ACCOUNT:-"default"}
echo "Deploying to $NETWORK using account $ACCOUNT..."
# Build the contract
echo "Building contract..."
cargo build --target wasm32-unknown-unknown --release -p clips_nft
WASM_PATH="target/wasm32-unknown-unknown/release/clips_nft.wasm"
# Ensure the WASM file exists
if [ ! -f "$WASM_PATH" ]; then
echo "Error: WASM file not found at $WASM_PATH"
exit 1
fi
# Deploy the contract WASM
echo "Installing WASM on-chain..."
WASM_HASH=$(soroban contract install --network "$NETWORK" --source "$ACCOUNT" --wasm "$WASM_PATH")
echo "WASM installed with hash: $WASM_HASH"
# Deploy the contract instance
echo "Deploying contract instance..."
CONTRACT_ID=$(soroban contract deploy --network "$NETWORK" --source "$ACCOUNT" --wasm-hash "$WASM_HASH")
echo "----------------------------------------"
echo "CONTRACT_ID: $CONTRACT_ID"
echo "----------------------------------------"
# Save contract ID to a file for later use
mkdir -p .soroban
echo "$CONTRACT_ID" > ".soroban/contract-id-$NETWORK"
# Initialization (optional, depends if it's already initialized)
# Here we initialize with the same account as admin
ADMIN_ADDRESS=$(soroban config identity address "$ACCOUNT")
echo "Initializing contract with admin: $ADMIN_ADDRESS..."
soroban contract invoke --id "$CONTRACT_ID" --source "$ACCOUNT" --network "$NETWORK" -- init --admin "$ADMIN_ADDRESS"
# Verification step using bindings
echo "Generating TypeScript bindings for verification..."
mkdir -p ./bindings
soroban contract bindings generate --id "$CONTRACT_ID" --network "$NETWORK" --output-dir ./bindings/clips_nft --overwrite
# Final verification: Call total_supply
echo "Verifying deployment by calling total_supply..."
TOTAL_SUPPLY=$(soroban contract invoke --id "$CONTRACT_ID" --source "$ACCOUNT" --network "$NETWORK" -- total_supply)
echo "Total supply: $TOTAL_SUPPLY"
if [ "$TOTAL_SUPPLY" == "0" ]; then
echo "Deployment verified successfully!"
else
echo "Verification failed: Unexpected total supply ($TOTAL_SUPPLY)"
exit 1
fi