Query and run commands
How to query and execute commands on your shiny new contract
Now you can check that the contract has assigned the right amount to the self-delegate address:
1
junod query wasm contract-state smart <contract-address> '{"balance":{"address":"<validator-self-delegate-address>"}}'
Copied!
From the example above, it will return:
1
data:
2
balance: "12345678000"
Copied!
Using the commands supported by execute work the same way. The incantation for executing commands on a contract via the CLI is:
1
junod tx wasm execute [contract_addr_bech32] [json_encoded_send_args] --amount [coins,optional] [flags]
Copied!
You can omit --amount if not needed for execute calls.
In this case, your command will look something like:
1
junod tx wasm execute <contract-addr> '{"transfer":{"amount":"200","owner":"<validator-self-delegate-address>","recipient":"<recipient-address>"}}' --from <your-key> --chain-id <chain-id>
Copied!

Passing arguments

As before, you can encode whatever JSON arguments you need via the node CLI (or another tool of your choice). But how do you know what arguments to use?
Every contract specifies the arguments that can be used for each action exposed to execute. Their types are also specified.
This specification, or spec, for short, can be found in the schema for the contract.
In the folder contracts/erc20 within cosmwasm-examples, for example, you can see the schemas:
1
tree schema
2
3
schema
4
├── allowance_response.json
5
├── balance_response.json
6
├── constants.json
7
├── execute_msg.json
8
├── instantiate_msg.json
9
└── query_msg.json
Copied!
Each of the JSON files above is a JSON schema, specifying the correct shape of JSON that it accepts.
Even though it is your job as a developer to provide documentation to your users, at a bare minimum, the schema will enforce argument correctness and provide basic documentation to others.
Last modified 5d ago
Copy link