description | cover | coverY |
---|---|---|
It's go time! |
../../.gitbook/assets/Gitbook Banner large 6 (1) (1) (1) (1) (1) (1) (1) (1) (31).png |
0 |
{% hint style="danger" %}
We don't specify it here, but in almost all cases you should provide an --admin
address when instantiating a contract. If you do not, you will not be able to migrate the contract later.
{% endhint %}
CosmWasm Smart Contracts take their arguments as serialised JSON. This can be created a number of ways, but as we showed in the previous examples, it may well be easiest to use the node
command line, if that is available to you.
{% hint style="info" %} There is a Typescript helpers file for most contracts, and extensions for CosmJS, but at the time of writing, they are broken. This will no doubt be fixed soon, providing an alternative way of interacting with contracts other than the CLI. {% endhint %}
To use the node REPL, type node
in the terminal.
const initobj = {
admins: ["<your-validator-self-delegate-key>"],
mutable: false
};
< undefined
JSON.stringify(initobj);
< '{"admins":["<your-validator-self-delegate-key>"],"mutable":false}'
With these encoded arguments, you can now instantiate the contract, using the code_id
from the previous step.
junod tx wasm instantiate <code-id> '{"admins":["<your-validator-self-delegate-key>"],"mutable":false}' --amount 50000ujunox --label "CW1 example contract" --from <your-key> --chain-id <chain-id> \
--gas-prices 0.1ujunox --gas auto --gas-adjustment 1.3 -b block -y
Once the contract is instantiated, you can find out its contract address:
junod query wasm list-contract-by-code <code-id>
You will need this to interact with the contract.