Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

san-npm/celottery

Repository files navigation

Celottery

Autonomous DeFi raffle protocol on Celo, operated entirely by a verified AI agent.

Live: celottery.vercel.app Contract (V3): 0x8a5859aB584f9b6F64769550862c58B9C5761C25 Agent Identity: ERC-8004 #34 | SelfClaw

What Is This

An AI agent creates raffles, sells tickets, draws winners with verifiable randomness, and splits fees — no human operator in the loop. Every action is on-chain, every draw is provably fair.

  • Stablecoins: USDT, USDC, USDm on Celo
  • Randomness: Aleph Cloud VRF — cryptographic proof stored on-chain
  • Treasury: 2-of-2 Safe multisig (0xaDA1...)
  • Fees: 95% winner / 3% platform / 2% organizer
  • Payments: x402 HTTP-native micropayments for ticket purchases

Anti-Rug Mechanics (V3)

  • Organizers stake in the same token as the raffle — skin in the game
  • Once tickets are sold, the organizer cannot cancel the raffle
  • Per-token decimal handling (6 dec for USDT/USDC, 18 dec for USDm)

Agent Identity

The agent operating Celottery is verified via:

  • SelfClaw — passport-based ZK proof of human backing (Self.xyz)
  • ERC-8004 — on-chain identity NFT (Token #34 on Celo)
  • Ed25519 keypair — cryptographic agent identity

Architecture

┌─────────────┐     ┌──────────────┐     ┌─────────────┐
│   Frontend   │────▶│  x402 API    │────▶│  Contract   │
│  (Next.js)   │     │  (Agent)     │     │  (Solidity) │
└─────────────┘     └──────┬───────┘     └──────┬──────┘
                           │                     │
                    ┌──────▼───────┐     ┌──────▼──────┐
                    │  Aleph VRF   │     │  Safe       │
                    │  (Randomness)│     │  (Treasury) │
                    └──────────────┘     └─────────────┘

Built with Scaffold-ETH 2 — Next.js, Hardhat, wagmi, viem.

Getting Started

# Install
git clone https://github.com/clementfrmd/celottery
cd celottery
yarn install

# Local dev
yarn chain          # Start local network
yarn deploy         # Deploy contracts
yarn start          # Start frontend at localhost:3000

Drawing Winners (Aleph VRF)

The draw uses Aleph Cloud VRF for verifiable randomness:

  1. Agent requests random number from Aleph VRF executor
  2. Aleph returns random number + cryptographic proof
  3. Agent calls drawWinner(raffleId, randomNumber, vrfHash) on-chain
  4. VRF proof hash stored on-chain for auditability
# TypeScript
npx ts-node scripts/draw-winner.ts <raffleId>

# Python
python scripts/draw_winner.py <raffleId>

If Aleph is unreachable, scripts fall back to local randomness (not verifiable — for testing only).

Contracts

Contract Address Network
AgentRaffleV3 0x8a5859aB584f9b6F64769550862c58B9C5761C25 Celo Mainnet
Treasury (Safe) 0xaDA1E751F2BB9b245Ca59a381f92394591233D71 Celo Mainnet

Environment Variables

Variable Description
__RUNTIME_DEPLOYER_PRIVATE_KEY Agent wallet private key
CELO_RPC_URL RPC endpoint (default: forno.celo.org)

Agent Token

$CLWDBRG — the agent's native token on Celo.

License

MIT

About

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors