Quickstart

Axiom Experimental SDK enables new features like Transactions and Receipts.

Transactions and Receipts are now available in our Experimental SDK. The experimental Axiom circuits generate mock proofs that are formatted in the same form as the final proof, but without proving the actual data.

Installation

You can use your favorite package manager (npm, yarn, pnpm) to install the Experimental SDK:

npm i @axiom-crypto/experimental@0.3.8

Setup

To set up the SDK, create a new instance of Axiom as follows:

const config: AxiomConfig = {
  providerUri: process.env.PROVIDER_URI_GOERLI || 'http://localhost:8545',
  version: "experimental",
  chainId: 5,
  mock: true,
};
const ax = new Axiom(config);

Create an instance of a signer (wallet) that can sign transactions:

const provider = new ethers.JsonRpcProvider(process.env.PROVIDER_URI_GOERLI as string);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string, provider);

Creating a Query

You can still create a regular block/account/state query using standard SDK methods. The new experimental Transactions and Receipts Query will have a maximum of 8 rows.

Warning

Each query produces a deterministic hash that can only be sent to the contract once. Therefore, you have to change the below data to be unique to your use case or else your transaction will revert.

Transactions & Receipts Query

To create a Transactions and Receipts Query (maximum of 4 Transactions and 4 Receipts rows), use the newTxReceiptsQueryBuilder convenience function to create a new builder instance:

const qb = ax.experimental.newTxReceiptsQueryBuilder();
await qb.appendTxQuery({
  txHash: "0x9ba6df3200fe8d62103ede64a32a2475e4c7f992fe5e8ea7f08a490edf32d48d",
  field: TransactionField.To,
});
await qb.appendTxQuery({
  txHash: "0x1320047d683efdf132b7939418a9f0061f9dfd7348a2f347f32745fb46cb6ec6",
  field: TransactionField.Data,
});
await qb.appendReceiptQuery({
  txHash: "0x1320047d683efdf132b7939418a9f0061f9dfd7348a2f347f32745fb46cb6ec6",
  field: ReceiptField.Status,
});
await qb.appendReceiptQuery({
  txHash: "0x1320047d683efdf132b7939418a9f0061f9dfd7348a2f347f32745fb46cb6ec6",
  field: ReceiptField.CumulativeGas,
});
await qb.appendReceiptQuery({
  txHash: "0x1320047d683efdf132b7939418a9f0061f9dfd7348a2f347f32745fb46cb6ec6",
  field: ReceiptField.Logs,
  logIndex: 0,
});
await qb.sendTxReceiptsQuery(wallet, wallet.getAddress(), {
  value: ethers.parseEther("0.01"),
  gasPrice: ethers.parseUnits("100", "gwei"),
});

Receipts-only Query

A Receipts-only Query can contain up to 8 Receipts. Use the newOnlyReceiptsQueryBuilder function to generate a new Builder instance:

const qb = ax.experimental.newOnlyReceiptsQueryBuilder();
await qb.appendReceiptQuery({
  txHash: "0x1320047d683efdf132b7939418a9f0061f9dfd7348a2f347f32745fb46cb6ec6",
  field: ReceiptField.Status,
});
await qb.appendReceiptQuery({
  txHash: "0x1320047d683efdf132b7939418a9f0061f9dfd7348a2f347f32745fb46cb6ec6",
  field: ReceiptField.Logs,
  logIndex: 0,
});
await qb.appendReceiptQuery({
  txHash: "0x1320047d683efdf132b7939ype418a9f0061f9dfd7348a2f347f32745fb46cb6ec6",
  field: ReceiptField.CumulativeGas,
});
await qb.sendOnlyReceiptsQuery(wallet, wallet.getAddress(), {
  value: ethers.parseEther("0.01"),
  gasPrice: ethers.parseUnits("100", "gwei"),
});

Experimental AxiomV1Query Contract

The Experimental AxiomV1Query contract is located at: 0xCa057924353E372d7c46F194ed0d75eABA7f1ed1

Events

When an Experimental Query is fulfilled, the contract emits the following event:

QueryFulfilled(uint8 queryType, bytes32 keccakQueryResponse, uint256 payment, address prover)

Example code

https://github.com/axiom-crypto/examples-experimental

Last updated