Writing an airdrop contract doesn’t need to be complex. With Sway, skip large contract files and unsafe hacks, just clean, secure and straightforward logic. Let’s dive into writing an airdrop contract in Sway. ⤵️
Handling airdrop logic in Sway is effortless: → Generate a Merkle root off-chain → Store this Merkle root in contract configurables → Verify proofs with `verify_proof()` function from the Sway_libs → Transfer assets directly to recipients
Here’s a quick overview of the contract structure 👇 Store your Merkle root, assetId and essential fields in the configurables:
Maintain claim states neatly in contract storage, alongside other required fields:
Proof verification? Just call the `verify_proof()` function from sway_libs directly in your `claim()` function
Once verified, transfer assets to your recipient with a single one-liner in your `claim()` function.
1.19K