Autonomous Airdrop
Let users autonomously qualify themselves for airdrops based on contract-specified criteria.
Introduction
This Autonomous Airdrop example checks if a user has used Uniswap on Goerli (swapping a token for a token that is not ETH) on or after block 9000000, and if so, sends 100 UselessToken to the user. UselessToken is a test token and has no monetary value.
Example Deployment
https://autonomous-airdrop-example.vercel.app/
Github Repo
https://github.com/axiom-crypto/autonomous-airdrop-example
System Diagram

Methodology
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 emit
s 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 topic
s and some amount of data. topic
s 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.

Swap
eventWe'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 UniswapUniversalRouter
on or after block 9000000, we want to use the following four pieces of data:
The
event schema
for the event (see note below for details), which always lives on topic index 0 of the event, matches theSwap
event aboveThe
recipient
field of theSwap
event matches the user's addressThe
receipt
'sblockNumber
is >= 9000000The
transaction
'sto
field matchesUniswapUniversalRouter
's contract address
Finding appropriate transactions
We utilize Alchemy's Transaction JSON-RPC to grab all transactions from the user that fit the criteria that it was sent from the user's address to the UniswapUniversalRouter's address. For each transaction, we get the receipt as well and then we parse through that data according to the 4 parameters outlined above to find an appropriate Event that matches.
Components
This example contains 3 parts: the AxiomREPL code, contracts, scripts, and webapp. AxiomREPL Code is the code that's written in using AxiomREPL to generate a ZK circuit in browser that can be used in your web app. Contracts contains all of the Solidity contract code to implement preprocessing the transaction data. Web App contains the code for a Next.js 13 (app router) web app.
AxiomREPL CodeContractWeb AppLast updated