Sign in

Merkle airdrop

he Merkle Airdrop is a real production pattern: one program that lets users claim an allocation by either proving they're on a fixed list of recipients or by presenting a signature from a trusted authority. The two paths are independent, but they share an anti-double-claim guard so any user can only claim once across both.

The interesting work isn't the Anchor scaffolding. You've done that. The interesting work is the verification logic itself. You implement Merkle proof verification by hand: hash the leaf, walk the proof, compare against the stored root. You implement signature verification by hand: build the message bytes, call ed25519 verification, reject if the signature doesn't match. There's no library you reach for that does this for you. The constraint is deliberate, because understanding how these primitives work is what separates someone who can use them safely from someone who can't.

The signature path has a subtle security requirement worth thinking about before you start. A signed message of just amount lets anyone who sees the signature claim on behalf of the original recipient. Once a signature is on chain, it's public. So the message has to bind both to the specific claimant and to this specific deployment of the program. Otherwise someone observes a successful claim, copies the signature, and replays it against their own wallet, or against the same wallet on a different program. Get this part wrong and an attacker drains the vault. Get it right and the signature is a single-use, recipient-bound, deployment-bound authorization.

You also write the off-chain pieces this time. Building the Merkle tree, producing proofs, generating signatures from the authority key. The conventions you pick off-chain have to match what the program verifies on-chain, exactly. A mismatch in the byte order of one field, or in whether you hash leaves and nodes the same way, breaks everything. That coordination between on-chain and off-chain code is itself part of the lesson.

YOUR WORK

Paste link to your repository