Skip to content

Commit

Permalink
Modify contract deployment scripts for injective localnet
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Oct 30, 2023
1 parent 335550d commit ac9b752
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
19 changes: 12 additions & 7 deletions scripts/deploy_contract.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
BINARY=wasmd
CHAINID_1="wasm-test"
CONTRACT_PATH=./cosmwasm/artifacts/std_reference.wasm
BINARY=injectived
CHAINID_1="injective-1"
CONTRACT_PATH=./cosmwasm/artifacts/std_reference-aarch64.wasm
DEMO_MNEMONIC_1="pony glide frown crisp unfold lawn cup loan trial govern usual matrix theory wash fresh address pioneer between meadow visa buffalo keep gallery swear"
RPC="http://0.0.0.0:26657"

NODE="--node $RPC"
TXFLAG="$NODE --chain-id $CHAINID_1 --gas-prices 0.25stake --keyring-backend test --gas auto --gas-adjustment 1.3 --broadcast-mode=block -y"
TXFLAG="$NODE --chain-id $CHAINID_1 --gas-prices 0.25stake --keyring-backend test --gas auto --gas-adjustment 1.3 --broadcast-mode=async -y"
# network check
export DEMOWALLET=$($BINARY keys show demowallet1 -a --keyring-backend test --home ./data/$CHAINID_1) && echo $DEMOWALLET;
export RELAYWALLET=$($BINARY keys show rly1 -a --keyring-backend test --home ./data/$CHAINID_1) && echo $RELAYWALLET;
#$BINARY query wasm list-code $NODE

# deploy smart contract
$BINARY tx wasm store $CONTRACT_PATH --from $DEMOWALLET --home ./data/$CHAINID_1 $TXFLAG
sleep 2

#instantiate contract
$BINARY tx wasm instantiate 1 '{}' --label test --admin $DEMOWALLET --from $DEMOWALLET --home ./data/$CHAINID_1 $TXFLAG
sleep 2

# query contract address
CONTRACT=$($BINARY query wasm list-contract-by-code "1" $NODE --output json | jq -r '.contracts[-1]')
echo $CONTRACT

#sample transactions
ADD_RELAYERS='{"add_relayers": {"relayers": ["wasm1usr9g5a4s2qrwl63sdjtrs2qd4a7huh6qksawp"]}}'
ADD_RELAYERS='{"add_relayers": {"relayers": ["inj1p4szayprev5yml5f2l6uq39gyuzamq3juetup5"]}}'
$BINARY tx wasm execute $CONTRACT "$ADD_RELAYERS" --home ./data/$CHAINID_1 --from $DEMOWALLET $TXFLAG
sleep 2

RELAY='{"force_relay": {"symbol_rates": [["stake","30"]], "resolve_time":"10", "request_id":"1"}}'
$BINARY tx wasm execute $CONTRACT "$RELAY" --home ./data/$CHAINID_1 --from $DEMOWALLET $TXFLAG
$BINARY tx wasm execute $CONTRACT "$RELAY" --home ./data/$CHAINID_1 --from $RELAYWALLET $TXFLAG
sleep 2

QUERY='{"get_ref": {"symbol": "stake"}}'
$BINARY query wasm contract-state smart $CONTRACT "$QUERY" $NODE --output json
$BINARY query wasm contract-state smart $CONTRACT "$QUERY" $NODE --output json
14 changes: 7 additions & 7 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
BINARY=wasmd
BINARY=injectived
CHAIN_DIR=./data
CHAINID_1="wasm-test"
CHAINID_1="injective-1"
VAL_MNEMONIC_1="copper push brief egg scan entry inform record adjust fossil boss egg comic alien upon aspect dry avoid interest fury window hint race symptom"
DEMO_MNEMONIC_1="pony glide frown crisp unfold lawn cup loan trial govern usual matrix theory wash fresh address pioneer between meadow visa buffalo keep gallery swear"
RELAY_MNEMONIC_1="alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart"
Expand Down Expand Up @@ -30,16 +30,16 @@ echo $DEMO_MNEMONIC_1 | $BINARY keys add demowallet1 --home $CHAIN_DIR/$CHAINID_
echo $DEMO_MNEMONIC_1 | $BINARY keys add demowallet1 --home $CHAIN_DIR/$CHAINID_1 --keyring-dir=./cw-relayer --recover --keyring-backend=test
echo $RELAY_MNEMONIC_1 | $BINARY keys add rly1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test

$BINARY genesis add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show val1 --keyring-backend test -a) 100000000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1
$BINARY genesis add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show demowallet1 --keyring-backend test -a) 100000000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1
$BINARY genesis add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show rly1 --keyring-backend test -a) 100000000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show val1 --keyring-backend test -a) 100000000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1 --chain-id=$CHAINID_1
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show demowallet1 --keyring-backend test -a) 100000000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1 --chain-id=$CHAINID_1
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show rly1 --keyring-backend test -a) 100000000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1 --chain-id=$CHAINID_1

sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml
sed -i -e 's/pruning = "default"/pruning = "everything"/g' $CHAIN_DIR/$CHAINID_1/config/app.toml
sed -i 's/"time_iota_ms": "1000"/"time_iota_ms": "10"/'$CHAIN_DIR/$CHAINID_1/config/genesis.json


echo "Creating and collecting gentx..."
$BINARY genesis gentx val1 1000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --keyring-backend test
$BINARY gentx val1 1000000000000000000000stake --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --keyring-backend test

$BINARY genesis collect-gentxs --home $CHAIN_DIR/$CHAINID_1
$BINARY collect-gentxs --home $CHAIN_DIR/$CHAINID_1
6 changes: 3 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

BINARY=wasmd
BINARY=injectived
CHAIN_DIR=./data
CHAINID_1="wasm-test"
CHAINID_1="injective-1"

echo "Starting $CHAINID_1 in $CHAIN_DIR..."
echo "Creating log file at $CHAIN_DIR/$CHAINID_1.log"
$BINARY start --log_level trace --log_format json --home $CHAIN_DIR/$CHAINID_1 --pruning=everything --minimum-gas-prices=0.00001stake > $CHAIN_DIR/$CHAINID_1.log 2>&1 &
$BINARY start --log-level trace --log-format json --home $CHAIN_DIR/$CHAINID_1 --pruning=everything --minimum-gas-prices=0.00001stake > $CHAIN_DIR/$CHAINID_1.log 2>&1 &

0 comments on commit ac9b752

Please sign in to comment.