Quickstart
Typescript SDK for building Queries into Axiom.
Github repo
The Github repository for this Quickstart is located here:
https://github.com/axiom-crypto/axiom-quickstart/tree/v1
Create a new project
In the command line, create and initialize a new Node.js project with the following commands:
mkdir axiom-quickstart
cd axiom-quickstart
npm init
touch src/index.ts
Installation
You can use your favorite package manager (npm
, yarn
, pnpm
) to install the Axiom SDK:
Install the following additional packages:
Setup
Create a .env.local file to store your provider URI from Alchemy. You can do this in the terminal with the following command:
Fill in your .env
file with the following information:
Create a new tsconfig.json
file via:
The index.ts
file in a new src
folder inside the axiom-quickstart
project. Start by importing the Axiom SDK, Ethers.js, and Dotenv library at the top of the page:
Now let's set up a new instance of the Axiom SDK:
We'll create mock proofs (they are of the same form as real proofs, but verification will always pass) and submit them to Axiom on Goerli testnet.
Create an instance of a signer (wallet) that can sign transactions:
Creating a Query into Axiom
Depending on the historical data you want to query, you can add a QueryRow with block, account, or storage data:
block number
block hash
block number
address
nonce
balance
storage root
code hash
block number
address
slot number
slot value
Building a Query
You can build a query by using the newQueryBuilder
convenience function and appending data to it with its append
function:
Submitting a built Query to Axiom
Next we'll write a function to submit the query on-chain to Axiom:
For more details, see: Submitting a Query.
Running the Example
In order to run the whole thing, call buildQuery
and submitQuery
in a main function:
Run this via the following command:
Using the result
Once the QueryFulfilled
event is emitted, you can then use the dataset of the Query you just built in your smart contract.
AxiomV1Query Contract
The AxiomV1Query contracts are located at:
Mainnet: 0xd617ab7f787adF64C2b5B920c251ea10Cd35a952
Goerli: 0x4Fb202140c5319106F15706b1A69E441c9536306
Last updated