From e87e66dca9af69431b79c0b42e78c37102c22c6d Mon Sep 17 00:00:00 2001 From: gangov <6922910+gangov@users.noreply.github.com> Date: Thu, 21 Nov 2024 13:47:33 +0200 Subject: [PATCH] deployment-script --- scripts/deploy.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 scripts/deploy.sh diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..7c79e10 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,81 @@ +# Ensure the script exits on any errors +set -e + +# Check if the arguments are provided +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +IDENTITY_STRING=$1 +NETWORK="testnet" + +echo "Build and optimize the contracts..."; +echo "Building the contracts..."; + +make build > /dev/null +cd target/wasm32-unknown-unknown/release + +echo "Contracts compiled." +echo "Optimizing contracts..." + +soroban contract optimize --wasm phoenix_nft_collections.wasm +soroban contract optimize --wasm phoenix_nft_deployer.wasm + +echo "Contracts optimized." + +echo "Deploy and install the deployer contract and capture its contract ID and hash..." + +DEPLOYER_ADDR=$( +soroban contract deploy \ + --wasm phoenix_nft_deployer.optimized.wasm \ + --source $IDENTITY_STRING \ + --network $NETWORK +) + +DEPLOYER_WASM_HASH=$( +soroban contract install \ + --wasm phoenix_nft_deployer.optimized.wasm \ + --source $IDENTITY_STRING \ + --network $NETWORK +) + +echo "Deployer contract deployed and installed." + +echo "Deploy and install the collections contract and capture its contract ID and hash..." + +COLLECTIONS_ADDR=$( +soroban contract deploy \ + --wasm phoenix_nft_collections.optimized.wasm \ + --source $IDENTITY_STRING \ + --network $NETWORK +) + +COLLECTIONS_WASM_HASH=$( +soroban contract install \ + --wasm phoenix_nft_collections.optimized.wasm \ + --source $IDENTITY_STRING \ + --network $NETWORK +) + +echo "Collections contract deployed and installed." + +echo "Initialize deployer with the collections hash..." + +soroban contract invoke \ + --id $DEPLOYER_ADDR \ + --source $IDENTITY_STRING \ + --network $NETWORK \ + -- \ + initialize \ + --collections_wasm_hash $COLLECTIONS_WASM_HASH + +echo "Deployer initialized." + +echo "#############################" + +echo "Setup complete!" +echo "Deployer address: $DEPLOYER_ADDR" +echo "Deployer wasm hash: $DEPLOYER_WASM_HASH" +echo "Collections address: $COLLECTIONS_ADDR" +echo "Collections wasm hash: $COLLECTIONS_WASM_HASH"