Installation and Configuration

Setting up the Axiom SDK

To send an on-chain query into Axiom, you'll use the Axiom SDK. Constructing and submitting a query proceeds in three steps. You can also check out our starter repo at axiom-quickstart which helps you submit your first test query as quickly as possible.

SDK Installation

Start by installing the Axiom SDK:

# npm
npm i @axiom-crypto/core

# or yarn
yarn add @axiom-crypto/core

# or pnpm
pnpm add @axiom-crypto/core

SDK Configuration

To initialize the Axiom class, first create an AxiomConfig object, which requires:

  • providerUri: a JSON-RPC provider URI (e.g. from Infura or Alchemy)

    • A local Geth node would have format

    • A Infura URI would have format<INFURA_ID>

    • A Alchemy URI would have format<ALCHEMY_KEY>

  • chainId: the chainId of the EVM chain

    • We currently support 1 for mainnet and 5 for Goerli testnet

import { Axiom, AxiomConfig } from "@axiom-crypto/core";

const config: AxiomConfig = {
    providerUri: <your provider uri (such as from Alchemy, Infura, etc)>,
    version: "v1",    
    chainId: <chainId: 1 for mainnet, 5 for Goerli>
    mock: <mock: true for mock proofs (Goerli only), false for real proofs>    
const ax = new Axiom(config);

The Axiom class will enable all further interactions with the SDK.

The Axiom class includes several convenience methods for interacting with the onchain contracts and wraps calls to the Axiom API, which serves on-chain data that we have indexed for convenience. All data fetched from the Axiom API can always be replicated trustlessly from a standard archive node.

Ethers Installation and Configuration

Install Ethers.js with the following command:

npm i ethers

Configure ethers in your project. We'll use ethers to submit our query onchain.

import { ethers } from "ethers";
const providerUri = <your provider URI (such as from Alchemy, Infura, etc)>
const provider = new ethers.JsonRpcProvider(providerUri);
const wallet = new ethers.Wallet(<private key>, provider);
const axiomV1Query = new ethers.Contract(
    ax.getAxiomQueryAddress() as string, 

Make sure the providerUri that you provide matches with the chainId value passed in at the top of the config object (so if chainId is 5, then provide a providerUri for Goerli).

Last updated