Custom Smart Contract: OddEvenBetting Game Built a betting game where players bet ETH on odd/even...Custom Smart Contract: OddEvenBetting Game Built a betting game where players bet ETH on odd/even...
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
Custom Smart Contract: OddEvenBetting Game
Built a betting game where players bet ETH on odd/even. Win = 2x payout.
Contract
Uses Chainlink VRF for randomness. Main functions:
placeBet() - player picks odd/even
fulfillRandomWords() - Chainlink callbacks, pays winners
Owner controls for funding/withdrawing. Checks 2x bet amount first.
Testing
28 Foundry tests with VRF mock. Tested wins/losses, permissions, edge cases. 95% coverage.
Deployment
Sepolia testnet. Created VRF subscription, deployed, added as consumer, funded with 0.1 ETH. Cost ~0.02 ETH.
Made helper scripts. Key learning: VRF takes ~1 minute, no instant on-chain randomness.
Works great!

github.com

GitHub - Jo-joVictor/Foundry-Lottery-: A Lottery that allows users to pick between odd and even, then a random number is generated by Chainlink VRF, modulus(by 2) is used to check if the number is odd or even. And users are given 2X their input if their choice is correct.

A Lottery that allows users to pick between odd and even, then a random number is generated by Chainlink VRF, modulus(by 2) is used to check if the number is odd or even. And users are given 2X the…

Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started