From 63bed2b7ddbf87258c256062331f85289c76402c Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Sun, 26 Nov 2023 00:26:12 +0700 Subject: [PATCH] add deploy script --- .env.sample | 1 + .gitignore | 2 ++ deploy.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .env.sample create mode 100644 deploy.sh diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..8d45860 --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +KEYRING_PASSWORD=your_password diff --git a/.gitignore b/.gitignore index 76cbac3..00a0985 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ # optimization artifacts artifacts/ + +.env \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..b169b09 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,28 @@ +#!/bin/bash +source .env + +NODE="https://testnet.sentry.tm.injective.network:443" +USER="tuan_inj" +echo "Deploying LQ Express Smart Contract to Injective Chain" +TXID=$(yes $KEYRING_PASSWORD | injectived tx wasm store artifacts/lq_express_sm.wasm --from=$USER --chain-id="injective-888" --yes --gas-prices=500000000inj --gas=20000000 --node=$(echo $NODE) --output json | jq -r '.txhash') +echo "Transaction ID: $TXID" +# Wait for the transaction to be included in a block +echo "Waiting for the transaction to be included in a block" +sleep 10 +RES=$(injectived q tx $TXID --node=$(echo $NODE) --output json) +echo "Response: $RES" +# The following is an easier way to get the Code Id from the response: +CODE_ID=$(injectived q tx $TXID --node=$(echo $NODE) --output json \ +| jq -r '.logs[0].events[-1].attributes[-2].value' | tr -d '"' ) +# Instantiate the contract +echo "Code ID: $CODE_ID" +echo "Instantiating LQ Express Smart Contract" +# Prepare the instantiation message +INIT='{}' +yes $KEYRING_PASSWORD | injectived tx wasm instantiate $CODE_ID $INIT --from=$USER --chain-id="injective-888" --label="lq_express" --yes --gas-prices=500000000inj --gas=20000000 --node=$(echo $NODE) --admin $(yes $KEYRING_PASSWORD | injectived keys show $USER -a) +# Get the contract address +echo "Getting the contract address" +injectived query wasm list-contract-by-code $CODE_ID --node $NODE --output json +CONTRACT=$(injectived query wasm list-contract-by-code $CODE_ID --node $NODE --output json | jq -r '.contracts[-1]') +echo "Contract address: $CONTRACT" +