Nerd Zone
The technical breakdown of why PeetBet is the first truly provably fair, open-source gambling platform with zero ability to manipulate outcomes.
Why Every Other Casino Can Scam You
Traditional Online Casinos
- Random numbers generated on THEIR servers
- You trust them to be honest (LOL)
- No way to verify results weren't manipulated
- Closed source code - black box
- Can change odds without telling you
- "Provably fair" = marketing buzzword
PeetBet (On-Chain)
- Chainlink VRF - decentralized randomness
- ZERO trust required - verify everything
- Every result verifiable on Etherscan
- 100% open source on GitHub
- Odds hardcoded in immutable contract
- Mathematically impossible to cheat
Chainlink VRF: The Magic Behind Provable Fairness
Chainlink VRF (Verifiable Random Function) is a cryptographic primitive that generates random numbers that are provably random and tamper-proof. Here's why it's impossible to cheat:
Request Generated On-Chain
When a game starts, a random number request is generated with a unique seed that includes the block hash, request ID, and other unpredictable data.
requestRandomWords( keyHash, // Chainlink oracle identifier subscriptionId, // Our VRF subscription requestConfirmations: 3, // Wait 3 blocks callbackGasLimit, numWords: 1 // We only need 1 random number )
Chainlink Nodes Generate Randomness
Multiple independent Chainlink nodes compute the random number using their private keys. The computation is deterministic given the inputs, but the private keys are unknown to anyone - including us.
// Node computation (simplified) proof = VRF(privateKey, seed) randomValue = hash(proof) // Proof can be verified with public key!
Cryptographic Proof Verification
The random number comes with a cryptographic proof. The on-chain verifier contract checks this proof against Chainlink's public key. If the proof is invalid, the transaction reverts.
// Verification (done automatically) bool valid = vrfCoordinator.verify( publicKey, proof, randomValue ); require(valid, "Invalid VRF proof");
Winner Determined Fairly
The random value is used with a simple modulo operation to determine the winner. For coin flip: 0 or 1. For dice: 1 to N players. No manipulation possible.
// Coin Flip (2 players) winner = randomWords[0] % 2 == 0 ? playerA : playerB; // Dice Roll (N players) winningNumber = (randomWords[0] % currentPlayers) + 1; winner = players[winningNumber - 1];
Why It's IMPOSSIBLE For Us To Cheat
No Server Control
Random numbers come from Chainlink's decentralized oracle network, not our servers. We literally cannot influence them.
Immutable Code
Once deployed, the smart contract code cannot be changed. The winner determination logic is locked forever.
Public Verification
Every game result is recorded on Ethereum. Anyone can verify any game at any time on Etherscan.
Open Source
All our code is on GitHub. Security researchers, auditors, and users can verify there are no backdoors.
The Math: 256-bit Randomness
Chainlink VRF provides a 256-bit random number. Here's what that means in practical terms:
256 bits = Unguessable
2²⁵⁶ possible values = 115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936
That's more possible values than atoms in the observable universe. Brute-forcing is physically impossible.
Coin Flip Math
randomWord % 2 // Even number (50%) → Player A // Odd number (50%) → Player B Example: 0x7a3f...2c04 % 2 = 0 → Player A wins 0x1b8e...7f91 % 2 = 1 → Player B wins
Dice Roll Math (N players)
(randomWord % N) + 1 // Result: 1 to N (equal probability) Example (5 players): 0x7a3f...2c04 % 5 = 3 Winner = Player #4 (index 3 + 1) Probability: 1/5 = 20% each
Contract Architecture
PeerBet.sol (Main)
0x10ff96bf...f04751cf
- • Coin flip game logic
- • Dice room game logic
- • Balance management
- • VRF callback handling
- • Fee distribution
PeerBetViews.sol (Read)
0x0a444c1d...f255ed87
- • Analytics queries
- • Room batch fetching
- • Player stats
- • Platform statistics
- • Achievement tracking
Key Winner Determination Code
function fulfillRandomWords(uint256 requestId, uint256[] calldata randomWords) internal override {
// Check if this is a dice room request
uint256 diceRoomId = diceRequestIdToRoomId[requestId];
if (diceRoomId != 0) {
// Dice game: winner = (random % players) + 1
uint16 winningNumber = uint16((randomWords[0] % room.currentPlayers) + 1);
address winner = players[winningNumber - 1];
// ... distribute winnings
return;
}
// Coin flip: winner = random % 2
uint256 roomId = requestIdToRoomId[requestId];
GameRoom storage room = rooms[roomId];
// Pure 50/50 for P2P games
address winner = (randomWords[0] % 2) == 0 ? room.playerA : room.playerB;
// ... distribute winnings
}Don't Trust, Verify
Every claim we make is verifiable. Here's how you can check for yourself:
1. View Contract Source Code
See the exact code running on Ethereum. It's verified and readable.
2. Check VRF Subscription
Verify we're using real Chainlink VRF, not a fake oracle.
3. Audit Game Results
Every game has a transaction. Check the VRF callback and result.
4. Review GitHub Source
Full source code including tests. Fork it, audit it, run it locally.