Wasm

Send CosmWasm messages to the chain.

Available Commands

CommandDescription

Executes a wasm message.

Instantiates a contract by code Id.

Migrate a contract.

Queries a contract.

Upload a contract wasm.

Queries general information about the contract.

Queries base information about the ADO.

Execute

Executes a wasm message.

Usage

wasm execute <contract address> <message>

Flags

FlagDescriptionUsage

funds

Funds to send with the message

--funds 100uandr

memo

An optional memo to attach to the message

--memo 'Wow what a great transaction!'

simulate

Simulates the transaction without broadcasting it. Useful to estimate gas costs.

-- simulate

help

Displays info about the current command.

--help

Example

? main-star@elgafar-1> wasm execute stars12w4nvet0fr2kh8a6xg594d4fd3tkwulrpy55nawh8s0y2z584pjsq4w2cq '{"deposit": {}}' --funds 10000ustars

The CLI will promt a confirmation. After confirming, the output is similar to:

– Executing Tx...

Transaction executed!

https://testnet-explorer.publicawesome.dev/stargaze/tx/042353250E0D6C67C320195032CB0BB7EDE1873F2434426A9812551ED4206E3E

The link will take you to the explorer to see the transaction details.

Instantiate

Instantiates a contract by code Id.

Usage

wasm instantiate <code-id> <instantiate message>

Flags

FlagDescriptionUsage

label

Used to provide a label assigned to the instantiation.

--label 'This is a great label'

admin

Used to provide an alternative admin address for the contract.

--admin andr1...

simulate

Simulates the transaction without broadcasting it. Useful to estimate gas costs.

--simulate

print

Prints the constructed message before simulating.

--print

help

Displays info about the current command.

--help

Example

? main-star@elgafar-1> wasm instantiate 3886 '{"kernel_address":"stars130mz3y4ajamadf9u5df7xh64t5ed5h3cxechz3jw43qdrc7wm09sxtykmx"}'
– Simulating Instantiation Tx...
Transaction simulated!

Cost Estimates
Gas Used: 211327
Fee estimates:
   5284ustars

? Do you want to proceed? Yes
- Instantiating your contract...

Contract instantiated!

https://testnet-explorer.publicawesome.dev/stargaze/tx/75184641D8275A5B34183CF31181C563FB6E4D007FC7BBC805D2DA43892BBBD7
Address: stars1zkug84swrqhvxupsuk4zu93zdcgva02uwlfk2095py39n7243vnq3dxd7y

The transaction link, as well as the new contract address are returned.

Migrate

Migrates a contract.

Usage:

wasm migrate <contract address> <new code id> <migrate msg>

Example:

wasm migrate 126 stars1zkug84swrqhvxupsuk4zu93zdcgva02uwlfk2095py39n7243vnq3dxd7y {}

Query

Performs a contract query.

Usage

wasm query <contract address> <query object> 

Example

? main-star@elgafar-1> wasm query stars1zkug84swrqhvxupsuk4zu93zdcgva02uwlfk2095py39n7243vnq3dxd7y {"get_locked_funds_for_recipient":{"recipient":"stars1dtlndrtpth240retkn8l54w8gg2g4hzpq3ugas"}}

Unlike the other messages, the query does not require single quotes around the message.

Here I am queriying the account of a user (which is empty) from one of our contracts, we get:

[] 

Upload

Upload a contract wasm.

The path is relative to where the CLI was run.

Usage

wasm upload <wasm file> 

Example

wam upload andromeda_app_contract.wasm

Info

Query general information about the ADO.

Usage

wasm info <contract-address>

Example

? user-3-renamed@galileo-4> wasm info andr1wcs8z2h7nfxfshukh6ys49pcxgnhq6ht7em7ap8z9n0pvxueqzmswqj7tq
- Querying contract info...

Creator:      andr10whczsw3tgqjrdd8t09s6c9a43w7dk09plelsqm937fpqar2c9gqqpgta0
Admin:        andr1c397rxvhf8mhj3rnhpmyqsrgg230y4vg4m3zpx                    
Code ID:      222                                                            
Label:        Instantiate: [email protected]                             
IBC Port ID:  None                                                           

? user-3-renamed@galileo-4> () 

Query Raw

Queries base information about the ADO.

Usage

wasm query-raw <contract-address>

Example

? user-3-renamed@galileo-4> wasm query-raw andr1wcs8z2h7nfxfshukh6ys49pcxgnhq6ht7em7ap8z9n0pvxueqzmswqj7tq
⠂ Querying contrac key...

ado_type
"timelock"

app_contract
"andr10whczsw3tgqjrdd8t09s6c9a43w7dk09plelsqm937fpqar2c9gqqpgta0"

block_height
3209082

contract_info
{"contract":"timelock","version":"2.0.2-beta.1"}

kernel_address
"andr14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9shptkql"

original_publisher
"andr10whczsw3tgqjrdd8t09s6c9a43w7dk09plelsqm937fpqar2c9gqqpgta0"

owner
"andr1dzrcm9swj22v2d05sqfktlwrz3u8hskgujyqhk"
FlagDescriptionUsage

limit

The number of resutls to return. Defaults to 10.

--limit 5

offset

Number of results to skip from the start. Defaults to 0.

--offset 3

Last updated

Additional Resources

GithubWebsite