Skip to main content

Client Integration

This guide shows how to interact with the Private Raffle program using TypeScript.

Setup

Derive PDAs

Helper Functions

Derive Allowance PDA

Decrypt Handle

Get Handle from Simulation


Step-by-Step Flow

1. Create Raffle

2. Buy Ticket with Encrypted Guess

3. Authority Draws Winning Number

4. Check If Won (Encrypted Comparison)

Currently, checking the result requires a transaction. When attested compute is introduced, this will be done off-chain without a transaction.

5. Claim Prize

6. Withdraw Prize (with On-Chain Verification)


Non-Winner Flow

When a player doesn’t win:
  1. check_winner returns encrypted false (decrypts to “0”)
  2. claim_prize uses e_select to set prize_handle to encrypted 0
  3. withdraw_prize fails with NotWinner error (prize amount is 0)

Running Tests

The test file includes both winner and non-winner flows to verify the entire system works correctly.