Raffles
The RaffleSDK and RaffleFactorySDK manage on-chain raffles powered by Algorand’s VRF (Verifiable Random Function) beacon.
Concepts
Section titled “Concepts”VRF Randomness
Section titled “VRF Randomness”Raffles use the Algorand VRF Randomness Beacon to select winners. This ensures provably fair, tamper-proof random selection.
Raffle Lifecycle
Section titled “Raffle Lifecycle”- Created — Raffle is set up with prize, ticket price, and duration
- Open — Users purchase tickets (entries)
- Drawing — VRF beacon is called to select a winner
- Complete — Winner claims the prize
Initialization
Section titled “Initialization”import { RaffleSDK, RaffleFactorySDK } from '@akta/sdk/raffle'
const raffleFactory = new RaffleFactorySDK({ algorand })
// Interact with an existing raffleconst raffle = new RaffleSDK({ algorand, factoryParams: { appId: raffleAppId },})Creating a Raffle
Section titled “Creating a Raffle”const raffle = await raffleFactory.newRaffle({ prizeAsset: nftAssetId, prizeAmount: 1n, ticketAsset: 0n, // Tickets cost ALGO startTimestamp: BigInt(Math.floor(Date.now() / 1000)), endTimestamp: BigInt(Math.floor(Date.now() / 1000) + 86400), // 24h minTickets: 10n, maxTickets: 100n, name: 'My NFT', proof: merkleProof, marketplace: marketplaceAddr, gateId: 0n, // No gate weightsListCount: 0n, // Even odds})Key Features
Section titled “Key Features”- Fair randomness — VRF beacon ensures provably random winner selection
- Configurable pricing — Set ticket price and maximum entries
- Time-limited — Raffles have configurable duration
- Double-sided fees — Both listing and purchasing platforms can take fees
- DAO fees — Raffle creation and entry fees controlled by governance
Raffle operations through a wallet use the RafflePlugin. See Wallet Plugins.