Smart Queries
Smart Queries are the queries a developer defines as part of their smart contract. They are typically JSON-encoded by convention, but a smart contract developer is technically free to choose any other format - though they should prepare for the backlash from the wider community. ;)Raw Queries
Raw Queries are extremely low-level and require knowledge of the storage layout of a smart contract. In CosmWasm, state is stored as pairs of binary keys and binary serialized values. As most smart contracts use cw-storage-plus, the format of these keys is typically the same, and Apophis can simplify raw storage lookup. If you need to access non-standard raw storage, you can still use theCosmos.rest(network)
endpoint directly.
Uint8Array
directly and it will be used as-is, in case your smart contract does
not use cw-storage-plus
and thus does not adhere to the standard format.
State Queries
State Queries are related to Raw Queries. They facilitate iterating over the entire low-level storage of a smart contract with pagination. However, as items of lists and maps are stored in cw-storage-plus, the format of these keys is typically the same, and Apophis can simplify raw storage lookup. If you need to access non-standard raw storage, you can still use theCosmos.rest(network)
endpoint directly.
About Key Paths
CosmWasm uses a simple key/value storage system - at the time of writing, this was LevelDB. However, to support complex data structures like maps and lists, the keys are prefixed and encoded to binary. This encoding follows a simple algorithm conveniently accessible through 3 methods:encodeKeypath
naturally encodes a keypath into a binary string. decodeKeypath
is its inverse.
And decodeKeypathMaybe
is a variant that returns null
if the keypath is not valid rather than
throwing an error.
The encodeKeypath
method is used under the hood by CosmWasm.query.raw
.
Contract Info Queries
Contract Info Queries are non-RPC queries, i.e. they are not defined in the RPC directly but are defined as a standard on a Raw Query through the CW2 standard. CW2 defines thecontract_info
storage key, which contains the name and version of a smart
contract. Apophis simply fetches this value using its own Raw Query implementation. It contains
the name and version of the smart contract as defined by its developer (i.e. may contain untruths).