This repo contains the source code for rafflebot.xyz, a smart contract based daily raffle platform. Rafflebot is secured by WorldID, which ensures that participants can only enter each raffle once. Deployed to the Goerli testnet.
Built with the following technologies:
- WorldID: Privacy preserving, proof-of-personhood protocol
- Hardhat: Smart contract development and testing
- wagmi.sh: React hooks for Ethereum
- ConnectKit: React components for connecting wallets
- Next.js: Static site builds and routing
- Tailwind: Adaptive CSS page styling
- Vercel: Web hosting and automatic deployments
Rafflebot is currently in MVP stage. There are a number of features to be added before the app could be considered complete:
- Fully integrate with WorldID at the smart contract level. The current implementation could be gamed by a malicious user, which would violate the one-person, one-entry rule
- Morph the smart contract into a NFT dispenser, giving the raffle winner a token for their prize
- It might also be worth considering an integration with POAP, in lieu of custom NFTs
- Notify winners using Push Protocol, in case they are not chain-savvy
- Make the raffle reusable and user-contributable, allowing users to add their own tokens/NFTs/etc. to a shared pot
- Add a full suite of tests covering all smart contract functions
To build your own copy of rafflebot, you will first need:
- Infura API key(s) for your chosen networks
- Etherscan API key for contract verification
- Deployer wallet private key with some (test) ETH
Clone the repo locally with the following commands:
git clone https://github.com/maxpetretta/rafflebot.xyz
cd rafflebot.xyz/hardhat
npm install
Place all of the above secrets in the .env file
You can deploy the contract with the included script file, use these commands:
npx hardhat run scripts/deploy.js --network <NETWORK_NAME>
npx hardhat verify --network <NETWORK_NAME> <CONTRACT_ADDRESS>
If running locally, you may skip the verify
step. A local testnet can be started with npx hardhat node
.
The website UI needs the contract to exist before it will function correctly. After you've completed the above, you should update the contract details in contract.ts. Make sure the address and ABI are in-sync with the live deployment. To start the frontend, run:
cd ../react
npm install
npm run dev
open http://localhost:3000
As mentioned above, Rafflebot is currently a MVP. Basic scaffolding for contract tests can be found in tests.ts. Before a mainnet deployment, a comprehensive suite of tests should be written.
Running tests is done by:
cd ./hardhat
npx hardhat test