Skip to content

Base Raffle Kit A Starter kit for random picks / raffles on the Base network.

License

Notifications You must be signed in to change notification settings

Adrijan-Petek/base-raffle-kit

Repository files navigation

Base Raffle Kit

A professional starter kit for random picks / raffles on the Base network.

✅ Hardhat + OpenZeppelin
✅ Commit–reveal style seed
✅ Deploy + draw scripts
✅ GitHub Actions CI (lint/compile/test)

⚠️ For real money raffles, don’t rely on blockhash RNG. Use VRF / verifiable randomness.


Install

npm install

Env

Copy .env.example.env and fill RPC + key.

Local

npm run compile
npm test

Deploy (Base Sepolia)

npm run deploy:base-sepolia

Run a raffle

1) Create seed + commit

node -e "const { keccak256, toUtf8Bytes, solidityPacked } = require('ethers'); const seedReveal = keccak256(toUtf8Bytes('my-secret')); const seedCommit = keccak256(solidityPacked(['bytes32'], [seedReveal])); console.log('SEED_REVEAL=', seedReveal); console.log('SEED_COMMIT=', seedCommit);"

2) Open

Call open(startTime,endTime,entryFeeWei,seedCommit) as owner.

3) Players enter

Players call enter() and pay the entry fee.

4) Close

After endTime, owner calls close(). Contract records drawBlockNumber = block.number + 1.

5) Reveal + draw

Wait 1–2 blocks, then:

RAFFLE_ADDRESS=0x... SEED_REVEAL=0x... npm run draw:base-sepolia

GitHub Actions

CI runs on every push/PR:

  • npm ci
  • npm run lint
  • npm run compile
  • npm test

If npm ci fails: run npm install locally and commit the updated package-lock.json.


License

MIT