Explanation of the different QueryBuilderV2 methods available in the Axiom SDK for building and submitting Queries.
The Axiom SDK is an npm library with a collection of APIs and query tools.
To install the package into your dApp as a project dependency, use your favorite package manager (npm, yarn, or pnpm)
npm
npmi@axiom-crypto/core
Building and Submitting Queries
The QueryBuilderV2 class which helps users construct queries in the Axiom Query Format and submit them on-chain. An instance of QueryBuilderV2 is created by the following call:
import{Axiom,QueryV2}from"@axiom-crypto/core";constaxiom=newAxiom({providerUri:process.env.PROVIDER_URI_GOERLIasstring,privateKey:process.env.PRIVATE_KEY_GOERLIasstring,version:"v2",chainId:5,// Goerlimock:true,// generate Mock proofs for faster development});constquery= (axiom.queryasQueryV2).new();
setDataQuery
setDataQuery(dataQuery: UnbuiltSubquery[])
Sets the dataQuery to an array of UnbuiltSubquery objects.
Appends an already-built DataQuery. This is used when receiving a DataQuery from a ComputeQuery. Setting this will take precedence over setting any UnbuiltSubqueries via append()/appendDataSubquery().
Used for pinning the encoded Query data to IPFS. The user still submits a transaction on-chain for the Prover to start the proving process, but instead of sending the encoded Query data as calldata, the user will include an IPFS CID hash which the Prover can then use to get the Query, decode it, and generate a ZK proof of it.
append
append(dataSubqueries: UnbuiltSubquery[]): void
Appends a UnbuiltSubquery[] object to the current dataQuery
Appends a single subquery to the current dataQuery. Developers can optionally pass the type of the subquery to append. If one is not provided, the type will be inferred from the keys of the subquery.
getQuerySchemaHash
getQuerySchema(): string
Returns the hash of the querySchema of the computeQuery
getDataQueryHash
getDataQueryHash(): string
Returns the hash of the data query
getQueryId
getQueryId(caller?: string): Promise<string>
Returns a uint256 queryId for a built Query (requires `privateKey` to be set in AxiomConfig if no `caller` is supplied to the function)
calculateFee
calculateFee(): string
Returns the amount of wei required to send this query
{
// Maximum fee per unit of gas for callback
maxFeePerGas?: string
// Gas limit you are willing to set for the callback
callbackGasLimit?: number
// Warn if the calldata size is above this threshold
dataQueryCalldataGasWarningThreshold?: number
// The address that can claim the refund for any unused Ether
refundee?: string
}
{
maxFeePerGas?: string
callbackGasLimit?: number
dataQueryCalldataGasWarningThreshold?: number
refundee?: string
}