In this section we will explain the steps involved in building a project that uses Axiom. We will build an Autonomous Airdrop app which allows a user to prove that they performed a
Swap in the UniV3 UNI-WETH pool on Sepolia after block 4,000,000. If a user fulfills this criterion, our contract will send 100
UselessToken to them.
To follow along with the finished product, you can see:
and a system diagram for the full application
Setting up the repo
To get started, we will use the Axiom starter command:
For the airdrop parameters that we've specified, we'd like to figure out exactly how we can get this data from the blockchain. First, we'll dive a little deeper into how event logs work.
When a Solidity contract
emits an event, that event is saved in the transaction receipt's
logs array. This array contains every event that was emitted during that transaction. Each
log records up to 3
topics and some amount of data.
topics are marked as
indexed in the event and are easily searchable, whereas data is any field without
indexed and is not as easily searchable. Here's an example
Swap event at this transaction here that we're interested in for our airdrop parameters.
We're looking at one example transaction right now, but the guidelines we'll build will be universal for all transactions. In order to show that a user has performed a
Swap on the UniV3 UNI-WETH pool on or after block 4,000,000, we want to use the following four pieces of data:
eventSchemafor the event, which always lives on topic index
0of the event, matches the
recipientfield of the
Swapevent matches the user's address
blockNumberis >= 4,000,000
addressfield matches the UniV3 UNI-WETH pool's contract address
This tutorial contains 3 main sections: the Axiom circuit, Axiom client contract, and webapp. Axiom Circuit is the user-specified ZK circuit written in Typescript that is the basis of the Axiom webapp functionality. Axiom Client Contract contains all of the Solidity contract code to implement preprocessing the transaction data. Web App contains the code for a Next.js 14 web app.