Axiom V2 Docs Old
  • Introduction
    • What is Axiom?
    • Quickstart
  • Examples
    • Autonomous Airdrop
      • AxiomREPL Code
      • Contract
      • Web App
      • DataQuery-only Version
  • Developers
    • Axiom for Developers
    • Specifying a Query into Axiom
    • AxiomREPL
      • AxiomREPL Examples
    • Exporting a Client Side Prover
    • Handling Axiom Callbacks
    • Common Issues
      • Callback Debugging
  • SDK and REPL Reference
    • Axiom SDK Reference
      • QueryBuilderV2
      • Data Subqueries
        • Header Subquery
        • Account Subquery
        • Storage Subquery
        • Transaction Subquery
        • Receipt Subquery
        • Solidity Nested Mapping Subquery
    • AxiomREPL Reference
      • Circuit Types
      • Circuit Functions
      • Data Functions
      • Compute Functions
  • Protocol Design
    • Architecture Overview
    • Caching Block Hashes
    • Axiom Query Protocol
      • Axiom Query Format
    • ZK Circuits for Axiom Queries
    • Ethereum On-chain Data
    • Guardrails
  • Transparency and Security
    • KZG Trusted Setup
    • Contract Addresses
    • On-chain ZK Verifiers
    • Security
  • Zero Knowledge Proofs
    • Introduction to ZK
    • ZK Examples
    • Getting Started with halo2
    • halo2-repl
  • Additional Resources
    • Axiom V2 Explorer
    • Github
    • Website
    • Telegram
    • Discord
    • Axiom V1 Docs
Powered by GitBook
On this page
  1. SDK and REPL Reference
  2. AxiomREPL Reference

Circuit Functions

Most commonly used AxiomREPL functions

witness

This function creates a CircuitValue that can change between different runs of the circuit (think of it as a JavaScript let). For example, if you wanted to create a circuit that checks if a user's balance is above some threshold, you would make the user's address a witness so that the circuit could be used to prove that any address's balance is above the threshold.

/**
 * Creates a circuit variable from a number, bigint, or string.
 *
 * @param a - The raw circuit input.
 * @returns The witness cell.
 */
witness: (a: number | bigint | string) => CircuitValue;

constant

This function creates a CircuitValue that must be the same every time you run your circuit (think of it as JavaScript const). For example, from the example above, you could make the threshold a constant to enforce that every time the circuit is run, the same threshold is used.

/**
 * Creates a circuit constant from a number, bigint, or string.
 *
 * @param a - The raw circuit input.
 * @returns The constant cell.
 */
constant: (a: number | bigint | string) => CircuitValue;

log

The log(...) function is used to debug the value of a CircuitValue or a CircuitValue256 (or some array of them). This is useful for debugging and checking that the values inside the circuit are what you would expect.

/**
 * Logs the provided *circuit* values to the console. 
 * Use `console.log` for normal logging.
 *
 * @param args - The values to log (can be `CircuitValue`s or `CircuitValue256`s).
 */
log: (...args: (CircuitValue | CircuitValue256)[]) => void;

addToCallback

This function is used to add a values to the data which is passed to your contract when your query is fulfilled. You can call addToCallback a maximum of 128 times inside AxiomREPL. See Handling Axiom Callbacks for more info on setting up your contract to receive the the data you pass to addToCallback.

/**
 * Adds a circuit value to the callback. 
 * Values passed to this function will be passed to your
 * callback client contract on-chain by Axiom.
 *
 * @param a - The circuit value to add to the callback.
 */
addToCallback: (a: CircuitValue | CircuitValue256) => void;
PreviousCircuit TypesNextData Functions

Last updated 1 year ago