This starter repo is a guide to get you started making your first Axiom query as quickly as possible using the Axiom SDK and Axiom smart contract client. To learn more about Axiom, check out the developer docs at docs.axiom.xyz or join our developer Telegram.
A guide on how to use this repository is available in the Axiom Docs: Quickstart.
This repo contains both Foundry and Javascript packages. To install, run:
forge install
pnpm install # or `npm install` or `yarn install`
For installation instructions for Foundry or a Javascript package manager (npm
, yarn
, or pnpm
), see Package Manager Installation.
Copy .env.example
to .env
and fill in your JSON-RPC provider URL. If you'd like to send transactions from a local hot wallet on testnet also add a Sepolia private key.
⚠️ WARNING: Never use your mainnet private key on a testnet! If you use this option, make sure you are not using the same account on mainnet.
To run Foundry tests that simulate the Axiom integration flow, run
forge test -vvvv
IMPORTANT: Please update the chain ID in the environment variable name to the chain ID that you are running on, if not 11155111 (Sepolia testnet).
To send a query on Sepolia testnet (requires PRIVATE_KEY_11155111
in .env
file), run
npx tsx app/index.ts
# compile
npx axiom circuit compile app/axiom/average.circuit.ts --provider $PROVIDER_URI_11155111
# prove
npx axiom circuit prove app/axiom/average.circuit.ts --sourceChainId 11155111 --provider $PROVIDER_URI_11155111
# get parameters to send a query to Axiom using sendQuery
npx axiom circuit query-params <callback contract address> --refundAddress <your Sepolia wallet address> --sourceChainId 11155111 --provider $PROVIDER_URI_11155111
Install npm
or yarn
or pnpm
:
# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source ~/.bashrc # or `source ~/.zshrc` on newer macs
# Install latest LTS node
nvm install --lts
# Install pnpm
npm install -g pnpm
pnpm setup
source ~/.bashrc # or `source ~/.zshrc` on newer macs
Install Foundry. The recommended way to do this is using Foundryup:
curl -L https://foundry.paradigm.xyz | bash
foundryup