Giter Site home page Giter Site logo

mina-merkle-airdrop's Introduction

CI

Merkle Airdrop

This is an implementation of a private Merkle Tree based airdrop built using Mina smart contracts and snarkyJS, intended to have similar functionality to the popular a16z repo.

Without revealing their address (public key), a user can claim their airdrop. The presence of MerkleMap based nullifiers prevent double-claiming.

The zk-contract is also a custom token by way of inheritance.

User Functionality

Once the contract is deployed the following functionality is exposed:

Check Inclusion of account in Merkle tree dataset

checkSetInclusion(account: Account, path: MerkleWitnessInstance)

where:
account is the account you want to check
path is the merkle tree path and is generated off-chain

This method will throw if the account is not included in the airdrop data set.

Check if account has already claimed

checkClaimed(account: Account, path: MerkleMapWitness): bigint

where:
account is the account you want to check
path is the merkle map witness and is generated off-chain

This method will return 1 if already claimed, 0 otherwise.

Claim

  claim(
    account: Account,
    path: MerkleWitnessInstance,
    signature: Signature,
    mmWitness: MerkleMapWitness
  )

where:

account is the account you want to check
path is the merkle tree path and is generated off-chain
signature is an account private key signed permission slip to claim
mmWitness is a Merkle Map witness to correctly prove the airdrop has not already been claimed

Admin Functionality

Mint tokens

mint(
    receiverAddress: PublicKey,
    amount: UInt64,
    adminSignature: Signature
  )

where:
receiverAddress is receiving address
amount is the amount of tokens to mint
adminSignature is the admin private key signed permission slip

Set Merkle Root commitment

setCommitment(preImage: Field)

where:
preImage is the merkle root of the data set of addresses that are eligible

Installation

Prerequisites

Clone this repo

git clone [email protected]:aodhgan/mina-merkle-airdrop.git

and cd into mina-merkle-airdrop

Use correct NodeJs version

nvm use

or manually install NodeJs v18.8.0

How to build

Note: these commands do not work with yarn

npm run build

How to run tests

npm run test

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions or loss of transmitted information. In addition, any airdrop using these smart contracts should be conducted in accordance with applicable law. Nothing in this repo should be construed as investment advice or legal advice for any particular facts or circumstances and is not meant to replace competent counsel. It is strongly advised for you to contact a reputable attorney in your jurisdiction for any questions or concerns with respect thereto. Developer is not liable for any use of the foregoing, and users should proceed with caution and use at their own risk.

mina-merkle-airdrop's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.