AxiomREPL Code

The code for AxiomREPL


AxiomREPL allows users to write custom ZK circuits in Javascript. 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 AxiomREPL code in this section is to export it for use in our Web App that we'll build after this.

AxiomREPL is located at


We have the following inputs to our AxiomREPL code. These inputs are variables that can later be changed (outside of AxiomREPL) in your app. Once the circuit has been exported outside of AxiomREPL into your web app, a different blockNumber, txIdx, and logIdx for a different user's Swap transaction can be inserted by your web app and used in the circuit.

    "blockNumber": 9610835,
    "txIdx": 6,
    "logIdx": 3

Note: every transaction hash maps to a unique blockNumber and txIdx combination.


The following code implements logic for getting blockchain data and running compute over that data. The inputs from the input box are used here, but this code cannot be changed once it is exported into your web app. Only the variables in the input field above may be changed by your web app.

If you do need to change your code, it must be done in AxiomREPL and then re-exported (because the verifying key will be different).

AxiomREPL code
// `Swap(address,address,int256,int256,uint160,uint128,int24)` event schema
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 = receiptLog.topic(0, eventSchema);

// get the topic at index 2
let swapTo = receiptLog.topic(2, eventSchema).toCircuitValue();

// get the block number for receipt
let blockNum = receipt.blockNumber().toCircuitValue();

// get the `to` field of the transaction
let tx = getTx(blockNumber, txIdx);
let txTo =;

// adds each of our desired variables to the callback. The callback returns the 
// values as an array in the order that `addToCallback` was called. 

// logs all of the variables to the right side output panel for sanity check

Last updated