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. Developers

AxiomREPL

Specify custom compute over the history of Ethereum in Javascript.

PreviousSpecifying a Query into AxiomNextAxiomREPL Examples

Last updated 1 year ago

You can use to write a custom query into Axiom and integrate it into your web frontend. These custom circuits can include data queries and arbitrary computation on top of these data queries. The circuit is proven in-browser and can then be sent on-chain to the Axiom V2 prover, which will aggregate the user-supplied compute proof with proofs of the data queries. Once the aggregated proof is posted on-chain, the results of the compute proof are passed to a user-specified callback function for consumption.

AxiomREPL has been tested and works as expected in Google Chrome and Safari. AxiomREPL currently does not work in Firefox

Example

is an example to trustlessly prove the block number at which your account made its first transaction.

Circuit Input:

{
    "address": "0x897dDbe14c9C7736EbfDC58461355697FbF70048",
    "claimedBlockNumber": 9173677
}

AxiomREPL code:

// example AxiomREPL circuit to prove the first block an account transacted

// get the previous block number
const prevBlock = sub(claimedBlockNumber, constant(1));

//get the account at the previous block
const accountPrevBlock = getAccount(prevBlock, address);

// get the account nonce at the previous block and assert that it is 0
const prevNonce = accountPrevBlock.nonce().toCircuitValue();
checkEqual(prevNonce, constant(0))

// get the account nonce at the claimed block number
const account = getAccount(claimedBlockNumber, address);
const nonce = account.nonce().toCircuitValue();

//checks that nonce > 0 at the claimed block
checkLessThan(constant(0), nonce)

// add the address and blockNumber to the callback, for it to be passed
// as a result to the callback client contract
addToCallback(address)
addToCallback(claimedBlockNumber);

Replace the input address with your own address and claimedBlockNumber to the first block you made a transaction to prove your account age! Notice that if you supply the wrong claimedBlockNumber, the circuit will fail run. See AxiomREPL Reference for complete documentation about the functions available in AxiomREPL.

AxiomREPL
Here