forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·94 lines (81 loc) · 2.5 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·94 lines (81 loc) · 2.5 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Deploy the Soroban contract to Stellar network
#
# I designed this script to support both testnet and mainnet deployment.
# It requires the ADMIN_SECRET_KEY environment variable to be set.
#
# Usage:
# ./deploy.sh # Deploy to testnet (default)
# ./deploy.sh testnet # Deploy to testnet
# ./deploy.sh mainnet # Deploy to mainnet (use with caution!)
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
WASM_PATH="$SCRIPT_DIR/../split-escrow/target/wasm32-unknown-unknown/release/split_escrow.wasm"
# Default to testnet
NETWORK="${1:-testnet}"
echo "🚀 StellarSplit Contract Deployment"
echo " Network: $NETWORK"
echo ""
# Validate network
if [ "$NETWORK" != "testnet" ] && [ "$NETWORK" != "mainnet" ]; then
echo "❌ Error: Invalid network '$NETWORK'"
echo " Valid options: testnet, mainnet"
exit 1
fi
# Check if ADMIN_SECRET_KEY is set
if [ -z "$ADMIN_SECRET_KEY" ]; then
echo "❌ Error: ADMIN_SECRET_KEY environment variable is not set"
echo ""
echo "To deploy, set your secret key:"
echo " export ADMIN_SECRET_KEY='S...your_secret_key...'"
echo ""
echo "⚠️ Never commit your secret key to version control!"
exit 1
fi
# Check if soroban CLI is installed
if ! command -v soroban &> /dev/null; then
echo "❌ Error: soroban CLI is not installed"
echo ""
echo "Install it with:"
echo " cargo install soroban-cli"
exit 1
fi
# Check if WASM file exists
if [ ! -f "$WASM_PATH" ]; then
echo "❌ Error: Contract WASM not found at $WASM_PATH"
echo ""
echo "Build the contract first:"
echo " ./build.sh"
exit 1
fi
# Mainnet warning
if [ "$NETWORK" = "mainnet" ]; then
echo "⚠️ WARNING: You are deploying to MAINNET!"
echo " This will use real XLM for fees."
echo ""
read -p "Are you sure you want to continue? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "Deployment cancelled."
exit 0
fi
fi
echo "📦 Deploying contract..."
echo ""
# Deploy the contract
CONTRACT_ID=$(soroban contract deploy \
--wasm "$WASM_PATH" \
--source "$ADMIN_SECRET_KEY" \
--network "$NETWORK")
echo ""
echo "✅ Deployment successful!"
echo ""
echo "📋 Contract Details:"
echo " Network: $NETWORK"
echo " Contract ID: $CONTRACT_ID"
echo ""
echo "💾 Save this contract ID for future interactions."
echo ""
# Save contract ID to file
CONTRACT_FILE="$SCRIPT_DIR/../.contract-id-$NETWORK"
echo "$CONTRACT_ID" > "$CONTRACT_FILE"
echo "📁 Contract ID saved to: $CONTRACT_FILE"