Axiom V2 Docs
Comment on page

Client Circuit

The client circuit code


An Axiom Query is specified by writing a special Axiom client circuit using the Axiom Client SDK. We use it here to generate a circuit that proves our request for the parameters from the Swap event and the same transaction's to field.
The goal of writing the client circuit code in this section is to export it for use in our Web App that we'll build after this.
You can learn more about writing a client circuit here.


We have the following circuit inputs to our client circuit code. These inputs are variables that can be auto-parsed from the blockNumber, txIdx, and logIdx of a user's Swap transaction that your web app provides.
Circuit Inputs
export interface CircuitValueInputs {
blockNumber: CircuitValue;
txIdx: CircuitValue;
logIdx: CircuitValue;
Note: every transaction hash maps to a unique blockNumber and txIdx combination.
For example, the following can be parsed into CircuitValueInputs by the SDK:
blockNumber: 9610835,
txIdx: 6,
logIdx: 3


The following code implements logic for getting blockchain data and running compute over that data.
Axiom Client Code
export const circuit = async ({ blockNumber, txIdx, logIdx }: CircuitValueInputs) => {
const eventSchema =
// specify and fetch the data you want Axiom to verify
let receipt = getReceipt(blockNumber, txIdx);
let receiptLog = receipt.log(logIdx); //get the log at index 3
// get the topic at index 0 (event schema)
let swapSchema = await receiptLog.topic(0, eventSchema);
// get the topic at index 2
let swapTo = await receiptLog.topic(2, eventSchema);
// get the block number for receipt
let blockNum = await receipt.blockNumber();
// get the `to` field of the transaction
let tx = getTx(blockNumber, txIdx);
let txTo = await;
Last modified 11d ago