A cross-chain solution for POAP verification and prize distribution using Celo and Avalanche networks.
Contract | Network | Address |
---|---|---|
POAPVerifier | Celo Mainnet | 0x3449afc2fCF3D51DC892658f0c69E47286B078d4 |
Raffle | Avalanche C-Chain | 0x2e3b71cF183657582F03c44F35fECF235677C1ED |
This project implements a cross-chain solution for verifying POAP ownership and conducting a raffle:
- POAP Registration: Users mint POAPs on the Celo network, generating unique tokenIds for each participant
- Verification Process: The POAPVerifier contract validates POAP ownership
- Cross-Chain Raffle: Validated participants enter a Chainlink VRF-powered raffle on Avalanche
# Install dependencies
npm i
# Set up environment variables
cp .env-example .env
# Edit the .env file with your private keys and API endpoints
# Deploy Mock POAP contract
npm run testnet:deploy:mockpoap
# Deploy POAP Verifier contract
npm run testnet:deploy:poapverifier
# Mint test POAPs
npm run testnet:mint:poaps
- Using the Coordinator contract, execute
createSuscription()
and get subscriptionId from logs - Set environment variables for the Raffle contract in your
.env
file - Deploy raffle contract:
npm run testnet:deploy:raffle
- In Coordinator contract, execute
addConsumer(subId, raffleAddress)
- Fund the subscription with LINK tokens: execute
transferAndCall(coordinatorAddress, 1000000000000000000, abi.encode(subId))
from the LINK token contract - On the Raffle contract, execute
electWinners()
to randomly select winners
# Verify Mock POAP contract
npx hardhat verify --network alfajores <MOCK-POAP-ADDRESS>
# Verify POAP Verifier contract
npx hardhat verify --network alfajores --constructor-args poapVerifierArgs.js <POAP-VERIFIER-ADDRESS>
# Verify Raffle contract
npx hardhat verify --network fuji --constructor-args raffleArgs.js <RAFFLE-ADDRESS>
# Deploy POAP Verifier contract to Celo mainnet
npm run mainnet:deploy:poapverifier
# Verify the contract
npx hardhat verify --network celo --constructor-args poapVerifierArgs.js <POAP-VERIFIER-ADDRESS>
- On Chainlink Coordinator contract: execute
createSuscription()
and get subscriptionId from logs - Set environment variables for the Raffle contract
- Deploy raffle contract:
npm run mainnet:deploy:raffle
- In Coordinator contract, execute
addConsumer(subId, raffleAddress)
- Fund the subscription with LINK tokens: execute
transferAndCall(coordinatorAddress, 1000000000000000000, abi.encode(subId))
from the LINK token contract - On the Raffle contract, execute
electWinners()
to randomly select winners
# Verify Raffle contract
npx hardhat verify --network avalanche --constructor-args raffleArgs.js <RAFFLE-ADDRESS>
As users participated in the Denver Quest, they minted POAPs on the Celo network. Each minted POAP generated a unique tokenId associated with the participant's address.
After the POAP minting period, we extracted the events to create a list of all participants:
# Script to fetch events and compile list of participants
node events/index.js
# Generate token IDs and tokenId-owner pairs
node events/getIdsFromParticipants.js
This process generated:
tokenIds.json
: An array of all valid token IDstokenIdOwnerPairs.json
: An array of objects matching each tokenId to its owner
The registration period ended on March 16th. We finalized the process by:
- Submitting all tokenIds to the POAPVerifier contract for validation
- The verification transaction can be viewed here: Verification Transaction
- All registered users can be verified in this transaction: Registered Users
The final list of verified participants was then:
- Extracted from the POAPVerifier contract on Celo
- Imported into the Raffle contract on Avalanche C-Chain
- The Raffle contract used Chainlink VRF 2.5 to randomly and fairly select winners
The winner selection process was completed with the following transactions:
- Initial
electWinners()
execution: Transaction Hash - Chainlink VRF fulfillment (internal transaction): VRF Transaction Hash
- POAPVerifier (Celo): Validates POAP ownership and maintains the official list of participants
- Raffle Contract (Avalanche): Manages the selection of winners using Chainlink VRF for verifiable randomness
- Cross-Chain Integration: Manual transfer of verified participant list from Celo to Avalanche
For technical questions or contributions, please open an issue in this repository.