A contract that splits any token it receives between all humans
A smart contract that allows any human to register itself as a claimer (using World ID), and can receive ERC-20 transfers. The received tokens are then split between all of the registered claimers.
To make sure each human can only register one receiver account, we use Worldcoin's World ID protocol, which uses the Semaphore library to manage identity groups and verify zero-knowledge proofs.
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 register as claimers calling WLDSplit.register(RECEIVER_ADDRESS, SEMAPHORE_ROOT, NULLIFIER_HASH, SOLIDITY_ENCODED_PROOF)
.
After registering, anyone can call the claim function specified a registered wallet and the address of a token the contract holds to receive their proportional share, like so WLDSplit.claim(RECEIVER_ADDRESS, TOKEN_ADDRESS)
. A getOutstandingFor
view function is also provided for convenience.
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). Finally, deploy the SemaphoreAirdrop
contract with the Semaphore contract address, and the group id.
Right now, Worldcoin maintains a staging Semaphore instance instance (for use with our mock app and its faucet) on Polygon Mumbai. The address is 0x330C8452C879506f313D1565702560435b0fee4C
, and the group ID is 1
. A production instance will be deployed soon.
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.
This project is open-sourced software licensed under the MIT license. See the License file for more information.