Docs/Examples/Airdrop Distributor

AirdropDistributor (VRF Winner Selection)

Uses VRF to pick N winners from a registered address pool on a fixed schedule.


Overview

AirdropDistributor is a recurring airdrop contract. Addresses register themselves into a pool, and on a fixed schedule AutoLoop uses ECVRF to pick winnersPerDraw winners via a partial Fisher-Yates shuffle. Each winner receives prizePerWinner ETH minus a protocol fee.

PropertyValue
Base contractAutoLoopVRFCompatible
VRF usageWinner selection
Gas per tick~90k + 15k per winner
Sourceautoloop/src/agents/AirdropDistributor.sol
Tests18 passing (unit + fuzz)

Why AutoLoop + VRF Are Structurally Required

The trigger holder knows who wins before the call. With a deterministic or predictable RNG, whoever submits the draw transaction can compute all possible winners in advance and time the call to a favorable block. AutoLoop's ECVRF provides verifiable randomness with on-chain proof verification — the winner is only known after the transaction is mined.

Mechanics

  • Register/Deregister: any address calls register() or deregister() to enter/leave the pool
  • shouldProgressLoop: returns true when pool size ≥ winnersPerDraw and drawInterval has elapsed
  • Winner selection: Fisher-Yates partial shuffle using VRF randomness picks winnersPerDraw non-repeating addresses
  • Prize distribution: (totalPrize * PROTOCOL_FEE_BPS) / 10000 goes to protocol; remainder split equally among winners
  • Pool preservation: the full pool remains registered for the next draw — winners aren't removed

Revenue Model

  • 2% protocol fee on total prize per draw
  • AutoLoop gas fee per draw tick

Deploy

forge create src/agents/AirdropDistributor.sol:AirdropDistributor \
  --constructor-args 604800 3 100000000000000000 \
  --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

Args: drawInterval (seconds), winnersPerDraw, prizePerWinner (wei). Fund the contract with at least winnersPerDraw × prizePerWinner ETH before draws begin.

Dashboard

View AirdropDistributor on the AutoLoop Dashboard.