FAQs about Queries
What Libraries Are Available to Handle Queries?
-
The Query TypeScript SDK can be used to create query requests, mock query responses for testing, and parse query responses. The SDK also includes utilities for posting query responses
-
The Solidity
QueryResponse
abstract contract can be used to parse and verify query responses on EVM chains. See the Solana Stake Pool repository as an example use case -
QueryTest.sol
can be used for mocking query requests and responses in Forge tests -
The Go query package can also be used to create query requests and parse query responses
Note
A Rust SDK for Solana is being actively investigated by the Wormhole contributors. See the Solana Queries Verification repository as a proof of concept.
Are There Any Query Examples?
Certainly. You can find a complete guide on the Use Queries page. Additionally, you can find full code examples in the following repositories:
- Basic Example Query Demo
- Solana Stake Pool Example Query
- Solana Program Derived Address (PDA) / Token Account Balance Example Query
- Solana Queries Verification Example
What Is the Format of the Response Signature?
The Guardian node calculates an ECDSA signature using Sign
function of the crypto package where the digest hash is:
keccak256("query_response_0000000000000000000|"+keccak256(responseBytes))
See the Guardian Key Usage white paper for more background. Once this signature is created, the Guardian's index in the Guardian set is appended to the end.
Note
If you are used to ecrecover
you will notice that the v
byte is 0
or 1
as opposed to 27
or 28
. The signaturesToEvmStruct
method in the Query TypeScript SDK accounts for this as well as structuring the signatures into an IWormhole.SignatureStruct[]
.
Can Anyone Run a Query Proxy Server?
Permissions for Query Proxy are managed by the Guardians. The Guardian nodes are configured to only listen to a set of allow-listed proxies. However, it is possible that this restriction may be lifted in the future and/or more proxies could be added.
It is also important to note that the proxies don't impact the verifiability of the request or result, i.e., their role in the process is trustless.
What Does Queries Offer over an RPC Service
Wormhole Queries provides on-demand, attested, on-chain, verifiable RPC results. Each Guardian independently executes the specified query and returns the result and their signature. The proxy handles aggregating the results and signatures, giving you a single result (all within one REST call) with a quorum of signatures suitable for on-chain submission, parsing, and verification using one of our examples or SDKs.