forked from Servora/StellarCert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-contracts.sh
More file actions
117 lines (96 loc) · 3.51 KB
/
deploy-contracts.sh
File metadata and controls
117 lines (96 loc) · 3.51 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Soroban Contract Deployment Script
# This script deploys the StellarCert Soroban contracts to the Stellar network
set -e
# Configuration
NETWORK="${STELLAR_NETWORK:-testnet}"
ADMIN_SECRET="${SOROBAN_ADMIN_SECRET}"
RPC_URL="${SOROBAN_RPC_URL}"
if [ -z "$ADMIN_SECRET" ]; then
echo "Error: SOROBAN_ADMIN_SECRET environment variable is required"
exit 1
fi
if [ -z "$RPC_URL" ]; then
if [ "$NETWORK" = "testnet" ]; then
RPC_URL="https://soroban-testnet.stellar.org"
else
RPC_URL="https://soroban.stellar.org"
fi
fi
echo "Deploying contracts to $NETWORK network..."
echo "RPC URL: $RPC_URL"
# Build the contracts
echo "Building contracts..."
cd stellar-contracts
cargo build --target wasm32-unknown-unknown --release
# Deploy certificate contract
echo "Deploying certificate contract..."
CERT_WASM_HASH=$(soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/certificate_revocation.wasm \
--source "$ADMIN_SECRET" \
--rpc-url "$RPC_URL" \
--network-passphrase "$(soroban config network pass $NETWORK)" \
| tail -1)
echo "Certificate contract deployed with WASM hash: $CERT_WASM_HASH"
# Create certificate contract instance
CERT_CONTRACT_ID=$(soroban contract deploy \
--wasm-hash "$CERT_WASM_HASH" \
--source "$ADMIN_SECRET" \
--rpc-url "$RPC_URL" \
--network-passphrase "$(soroban config network pass $NETWORK)" \
| tail -1)
echo "Certificate contract instance created with ID: $CERT_CONTRACT_ID"
# Initialize certificate contract
echo "Initializing certificate contract..."
ADMIN_ADDRESS=$(soroban keys address "$ADMIN_SECRET")
soroban contract invoke \
--id "$CERT_CONTRACT_ID" \
--source "$ADMIN_SECRET" \
--rpc-url "$RPC_URL" \
--network-passphrase "$(soroban config network pass $NETWORK)" \
-- \
initialize \
--admin "$ADMIN_ADDRESS"
echo "Certificate contract initialized successfully!"
# Deploy multisig contract (if needed)
echo "Deploying multisig contract..."
MULTISIG_WASM_HASH=$(soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/certificate_revocation.wasm \
--source "$ADMIN_SECRET" \
--rpc-url "$RPC_URL" \
--network-passphrase "$(soroban config network pass $NETWORK)" \
| tail -1)
MULTISIG_CONTRACT_ID=$(soroban contract deploy \
--wasm-hash "$MULTISIG_WASM_HASH" \
--source "$ADMIN_SECRET" \
--rpc-url "$RPC_URL" \
--network-passphrase "$(soroban config network pass $NETWORK)" \
| tail -1)
echo "Multisig contract deployed with ID: $MULTISIG_CONTRACT_ID"
# Deploy CRL contract (if needed)
echo "Deploying CRL contract..."
CRL_WASM_HASH=$(soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/certificate_revocation.wasm \
--source "$ADMIN_SECRET" \
--rpc-url "$RPC_URL" \
--network-passphrase "$(soroban config network pass $NETWORK)" \
| tail -1)
CRL_CONTRACT_ID=$(soroban contract deploy \
--wasm-hash "$CRL_WASM_HASH" \
--source "$ADMIN_SECRET" \
--rpc-url "$RPC_URL" \
--network-passphrase "$(soroban config network pass $NETWORK)" \
| tail -1)
echo "CRL contract deployed with ID: $CRL_CONTRACT_ID"
# Output configuration
echo ""
echo "=== DEPLOYMENT COMPLETE ==="
echo "Add these to your .env file:"
echo "SOROBAN_RPC_URL=$RPC_URL"
echo "CERTIFICATE_CONTRACT_ID=$CERT_CONTRACT_ID"
echo "MULTISIG_CONTRACT_ID=$MULTISIG_CONTRACT_ID"
echo "CRL_CONTRACT_ID=$CRL_CONTRACT_ID"
echo "SOROBAN_ADMIN_SECRET=$ADMIN_SECRET"
echo "ENABLE_SOROBAN_INTEGRATION=true"
echo ""
echo "Admin address: $ADMIN_ADDRESS"