Skip to main content
CosmWasmClient provides multiple ways to read contract state: JSON smart queries that execute the contract’s query entry point, raw binary reads against storage keys, and metadata lookups for contracts and uploaded code.

Smart Queries

Smart queries execute the contract’s query entry point and return parsed JSON. The query message shape depends on the contract.
Smart queries are rejected if the contract address does not exist or the query message does not match the contract’s schema. Both cases throw an error.

Raw State Access

For direct storage reads, use queryContractRaw with the binary storage key:

Contract Metadata

Retrieve a contract’s on-chain metadata including its code ID, creator, admin, and label:

Code and Contract Discovery

List uploaded codes and find contracts by code ID or creator:
getCodes(), getContracts(), and getContractsByCreator() loop through all pagination pages internally. For large result sets, consider using the wasm query extension directly with manual pagination.

Using the Wasm Query Extension

For fine-grained control over pagination or when building a custom query client, use the wasm extension directly:

Next Steps

Uploading Code

Deploy Wasm binaries to chain.

Executing Contracts

Execute contract messages and parse events.