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.
| Property | Value |
|---|---|
| Base contract | AutoLoopVRFCompatible |
| VRF usage | Winner selection |
| Gas per tick | ~90k + 15k per winner |
| Source | autoloop/src/agents/AirdropDistributor.sol |
| Tests | 18 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()orderegister()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
winnersPerDrawnon-repeating addresses - Prize distribution:
(totalPrize * PROTOCOL_FEE_BPS) / 10000goes 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 --broadcastArgs: drawInterval (seconds), winnersPerDraw, prizePerWinner (wei). Fund the contract with at least winnersPerDraw × prizePerWinner ETH before draws begin.
Dashboard
View AirdropDistributor on the AutoLoop Dashboard.