Skip to content

World ID Example. Create an airdrop of ERC-20 tokens that can only be claimed once by a single human. Completely privacy preserving.

License

Notifications You must be signed in to change notification settings

worldcoin/world-id-example-airdrop

Repository files navigation

Zero-Knowledge Gated Airdrop

A template to airdrop an ERC-20 token to a group of addresses, while preserving privacy for the claimers.

This repository uses the Semaphore library to allow members of a set to claim an ERC-20 token, preserving their privacy and removing the link between the group and the claimer address thanks to zero-knowledge proofs.

Deployment

First, you'll need a contract that adheres to the ISemaphore interface to manage the zero-knowledge groups. If you don't have any special requirements, you can use this one. Next, you'll need to create a Semaphore group (Semaphore.createGroup(YOUR_GROUP_ID, 20, 0) should do the trick). You'll also need an address that holds the tokens to be airdropped (remember to grant access to the airdrop contract after deployment by calling ERC20.approve(AIRDROP_CONTRACT_ADDRESS, A_VERY_HIGH_NUMBER)). Finally, deploy the WorldIDAirdrop contract with the Semaphore contract address, the group id, the address of your ERC20 token, the address of the holder, and the amount of tokens to give to each claimer.

Usage

Since only members of a group can claim the airdrop, you'll need to add some entries to your Semaphore group first. End-users will need to generate an identity commitment (which can be done through the @zk-kit/identity or semaphore-rs SDKs). Once they have one, you can add it to the group by calling Semaphore.addMember(YOUR_GROUP_ID, IDENTITY_COMMITMENT).

Once users have identities included on the configured group, they should generate a nullifier hash and a proof for it (which can be done through the @zk-kit/protocols or semaphore-rs SDKs, using the address who will receive the tokens as the signal). Once they have both, they can claim the aidrop by calling WorldIDAirdrop.claim(RECEIVER_ADDRESS, NULLIFIER_HASH, SOLIDITY_ENCODED_PROOF).

You can see the complete flow in action on the WorldIDAirdrop tests.

Usage with Worldcoin

Worldcoin will maintain a Semaphore instance with a group for all the people that have onboarded to the protocol. Once the insance is deployed, we'll provide information here so you can point your WorldIDAirdrop instances to it, ensuring only unique humans can claim your airdrop.

Development

This repository uses the Foundry smart contract toolkit. You can download the Foundry installer by running curl -L https://foundry.paradigm.xyz | bash, and then install the latest version by running foundryup on a new terminal window (additional instructions are available on the Foundry repo). You'll also need Node.js if you're planning to run the automated tests.

Once you have everything installed, you can run make from the base directory to install all dependencies, build the smart contracts, and configure the Poseidon Solidity library.

About World ID

World ID is a protocol that lets you prove a human is doing an action only once without revealing any personal data. Stop bots, stop abuse.

World ID uses a device called the Orb which takes a picture align="center" of a person's iris to verify they are a unique and alive human. The protocol uses Zero-knowledge proofs so no traceable information is ever public.

World ID is meant for on-chain web3 apps, traditional cloud applications, and even IRL verifications.

Getting started with World ID

Regardless of how you landed here, the easiest way to get started with World ID is through the the Dev Portal.

World ID Demos

Want to see World ID in action? We have a bunch of Examples.

📄 Documentation

We have comprehensive docs for World ID at https://id.worldcoin.org/docs.

🗣 Feedback

World ID is in Beta, help us improve! Please share feedback on your experience. You can find us on Discord, look for the #world-id channel. You can also open an issue or a PR directly on this repo.

About

World ID Example. Create an airdrop of ERC-20 tokens that can only be claimed once by a single human. Completely privacy preserving.

Topics

Resources

License

Security policy

Stars

Watchers

Forks