Make sure you follow the guide first for your project. Once you have a contract compiled in the artifacts/*.wasm directory, you are ready for this guide.
This guide will show you how to deploy and interact with a contract using CLI. For scripting using Rust, you can use .
Upload
You need to upload the contract via the CLI to chain. To do this, perform the following
We can see both raw_log and also logs[0].events[1].store_code shows the code_id being 13. If you wish the automate this return code in bash to a variable, you can
Ensure you change CODE_ID to match your code id from the store code
# Manual
CODE_ID=1
junod tx wasm instantiate "$CODE_ID" '{"count":0}' --label "some-contract" $FLAGS -y --admin <your-address-here>
# then query the tranasaction hash as we do above.
# Automated return of the contract address
CODE_ID=1
TX_INIT=$(junod tx wasm instantiate "$CODE_ID" '{"count":0}' --label "contract" $FLAGS -y --admin <your-address-here> | jq -r '.txhash') && echo $TX_INIT
CONTRACT_ADDR=$($BINARY query tx $TX_INIT --output json | jq -r '.logs[0].events[0].attributes[0].value') && echo "CONTRACT_ADDR: $CONTRACT_ADDR"
With the code now being up on chain, we can now run logic to setup our own copy of the contract which we control. This will then give us a unique contract address for others to interact with in accordance with the contract logic. This example is from the .