Skip to content

feat(airdrop): implement Merkle-tree airdrop contract extension - #515

Open
Myart352 wants to merge 10 commits into
FinChippay:masterfrom
Myart352:feat/merkle-airdrop-475
Open

feat(airdrop): implement Merkle-tree airdrop contract extension#515
Myart352 wants to merge 10 commits into
FinChippay:masterfrom
Myart352:feat/merkle-airdrop-475

Conversation

@Myart352

@Myart352 Myart352 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #475

Summary

Adds a Merkle-tree-based airdrop mechanism to FinchippayContract enabling gas-efficient token distributions to thousands of recipients.

Changes

  • MerkleAirdrop struct: id, funder, token, merkle_root, total_amount, claimed_amount, expiration_ledger, cancelled
  • verify_merkle_proof() helper: Iterative SHA-256 Merkle proof verification using sorted hash concatenation
  • DataKey variants: AirdropCount, Airdrop(u32), AirdropClaimed(u32, Address)
  • create_airdrop(): Fund airdrop by transferring tokens to contract, store Merkle root and expiration
  • claim_airdrop(): Verify Merkle proof for (recipient, amount), prevent double-claims, transfer tokens
  • cancel_airdrop(): Funder cancels after expiration, refunds unclaimed tokens
  • View functions: get_airdrop(), get_airdrop_count()
  • 8 tests: single recipient, invalid proof, double-claim rejection, cancel after/before expiration, funder-only cancel, invalid params, 3-recipient tree

Fixes Applied

  • CI Workflow: Fixed YAML indentation in error-docs job (CI was silently skipped)
  • CI Trigger: Added master to pull_request trigger branches (CI only ran on main)
  • SDK 27.0 Compatibility: Fixed as_array()to_array(), Hash<32>/BytesN<32> conversions, added ToXdr import, added extern crate std for tests
  • Compilation: cargo check --target wasm32v1-none passes with 0 errors

Testing

  • 8 new airdrop-specific tests covering the full lifecycle
  • Existing contract tests continue to compile
  • cargo check passes cleanly on wasm32 target

Security

  • All mutating functions require auth and check pause state
  • Merkle proof verification prevents unauthorized claims
  • Claim tracking prevents double-claims
  • Expiration enforcement prevents premature cancellation

- Add MerkleAirdrop struct with id, funder, token, merkle_root, total_amount, claimed_amount, expiration_ledger, cancelled fields
- Add verify_merkle_proof() helper using iterative SHA-256 hashing
- Add DataKey variants: AirdropCount, Airdrop(u32), AirdropClaimed(u32, Address)
- Implement create_airdrop(): transfer total_amount to contract, store airdrop record
- Implement claim_airdrop(): verify Merkle proof, check not already claimed, transfer tokens
- Implement cancel_airdrop(): funder cancels after expiration, refunds unclaimed tokens
- Add get_airdrop() and get_airdrop_count() view functions
- Add 8 comprehensive tests covering single recipient, invalid proof, double claim, cancel after/before expiration, funder-only cancel, invalid params, and 3-recipient tree

Closes FinChippay#475
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Myart352 is attempting to deploy a commit to the Topmatrixmor2014 Team on Vercel.

A member of the Team first needs to authorize it.

@Topmatrixmor2014

Copy link
Copy Markdown
Contributor

Please fix CI

Myart352 added 4 commits July 29, 2026 14:00
- Add i18next-scanner to frontend devDeps, prettier to backend

- Fix duplicate logger imports, unused vars, parsing errors

- Fix corrupted migrate-status.js duplicate catch blocks

- Fix corrupted logger.js with duplicate keys

- Fix undefined Contract/TransactionBuilder/Account in analyticsService
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
finchippay-solution Error Error Jul 30, 2026 1:03am
finchippay-solution-qbnx Error Error Jul 30, 2026 1:03am

Myart352 added 2 commits July 30, 2026 19:18
Cherry-pick CI config fixes from commit 2530115:
- Fix YAML indentation in ci.yml
- Remove duplicate fuzz job
- Fix docker-publish.yml duplicate build steps
- Remove duplicate scripts in package.json
- Make output:"export" conditional on VERCEL env var so Vercel
  deployments use server mode while Docker builds stay static
- Update vercel-deploy.yml node version to match .nvmrc (22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merkle-Tree Airdrop Contract Extension

2 participants