Accessing Block and Query Information
Access block and query information from the Axiom SDK
We provide information about Ethereum blocks and Axiom queries via the Block
and Query
classes wrapped by the Axiom
class.
Block Information
Block information to use in reading from AxiomV1
is available from the Block
object ax.block
. The available API calls are as follows.
getBlockHashWitness
Returns a BlockHashWitness
to verify a single block hash against the cache in AxiomV1
in the isBlockHashValid
contract call.
getBlockRlpHeader
Returns the RLP-encoded block header of block blockNumber
.
getBlockMmrProof
Returns mmr
, claimedBlockHash
, and merkleProof
of the block hash of block blockNumber
to verify a single block hash against the cache in AxiomV1
using the mmrVerifyBlockHash
contract call.
Query Information
Information about queries into Axiom is available from the Query
object ax.query
. The available API calls are as follows.
getResponseTreeForQueryHash
Returns a ResponseTree
object containing the data associated with a queryHash
indexed by keccakQueryResponse
. This object is defined by:
and we can extract summary query responses from it by:
getResponseTreeForKeccakQueryResponse
Returns a ResponseTree
object in the same manner and interface as above.
Query response components can be obtained by:
getResponseTreeFromTxHash
Another way to get the ResponseTree
from is by passing in a transaction hash. The transaction hash must be the one from a successful sendQuery
call to AxiomV1Query
.
getValidationWitness
Fetches a Merkle proof and some other data that allows a user to prove that their claimed data is actually committed to in keccakQueryResponse
. This prepares the arguments for areResponsesValid
which checks the witness data against the keccakQueryResponse
which is already verified.
You can think of getValidationWitness
as the second step in a 3-step process of receiving and verifying a proof:
Receive a response from Axiom
Prove that the response you got from Axiom is actually what is in
keccackQueryResponse
Check that the data that gets passed into your smart contract is the same data as in step 2 with
areResponsesValid.
Returns SolidityBlockResponse
, SolidityAccountResponse
, and SolidityStorageResponse
objects which can be used to read query results from areResponsesValid
in AxiomV1Query
. The interface of the return object is as follows:
The result is:
SolidityBlockResponse
if neitheraddress
orslot
is providedSolidityAccountResponse
ifaddress
is provided, butslot
is notSolidityStorageResponse
if bothaddress
andslot
are provided.
To see an example of how getValidationResponse
is used, check out this example.
getQueryHashFromTxHash
Gets the queryHash
value from the transaction hash where the sendQuery
function in the AxiomV1Query
contract was called. Ensure that you are passing in the transaction hash from the sendQuery
function call.
getKeccakQueryResponseFromTxHash
Gets the keccakQueryResponse
from the transaction where the sendQuery
function in the AxiomV1Query
contract was called. Ensure that you are passing in the transaction hash from the sendQuery
function call.
Last updated