Inspiration
Traditional online gaming platforms often suffer from issues of trust and transparency. Players cannot be sure if the outcomes of games are genuinely random or if they have been manipulated. This lack of trust discourages users from participating, especially when it comes to games involving real money or valuable digital assets. We were inspired to create a decentralized gaming platform that leverages blockchain technology to ensure fairness, transparency, and security in every game.
What it does
Our platform, Wager Wheels, hosts various small games such as Rock-Paper-Scissors, Mines, and Spin the Wheel. By using Chainlink's Verifiable Random Function (VRF), it provides a trustless and transparent gaming experience where each game outcome is provably fair. Players can verify the randomness of results independently, ensuring that all outcomes are genuine and unmanipulated.
How we built it
Wager Wheels is built using a combination of smart contracts deployed on the Sepolia testnet and front-end development with Next.js. We integrated Chainlink VRF to generate verifiable random numbers for game outcomes, ensuring transparency and fairness. Alchemy was used to facilitate seamless blockchain interaction, providing robust and efficient access to the Ethereum network.
In Rock Paper Scissor game, we requested chainlink VRF to generate 5 random number of range 1-6 ( Total number of possible permutations = 6). Each random number is allocated to each row in game.
[[0,1,2],
[0,2,1],
[1,0,2],
[1,2,0],
[2,0,1],
[2,1,0]]
where 0 -> Rock, 1 -> Paper, 2 -> Scissor
In Spin The Wheel game, we want only 1 random number of range (0-5) which will help in generating angle at which wheel need to stop.
Angle = (Random/6) * 360
In Mines game, we implemented the Fisher–Yates Shuffle Algorithm to avoid repeatable random numbers. This algorithm is designed to produce a random permutation of a finite sequence—in this case, the placement of mines. The Fisher–Yates Shuffle works as follows:
- Start with an array of elements.
[ 1, 2, 3, 4, 5 ..................... 25 ]
- Iterate through the array from the last element to the first.
- For each element, generate a random index within the portion of the array that has not been shuffled yet.
- Swap the current element with the element at the randomly generated index.
- After shuffling the array, we just take first n number of elements from array where n is number of mines. Resulting array will be a set of of elements of range [1-25] on which mines will be laid.
By using the Fisher–Yates Shuffle, we ensure that each placement of mines is unique and unpredictable, enhancing the fairness and enjoyment of the game.
function fisherYatesShuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
Challenges we ran into
One of the main challenges was integrating Chainlink VRF with our smart contracts and ensuring that the random numbers generated were correctly utilized in our game logic. Additionally, optimizing the user experience while maintaining security and transparency was a complex task. We also encountered difficulties with ensuring seamless interaction between the front end and blockchain elements.
Accomplishments that we're proud of
We are proud of successfully creating a decentralized platform that addresses the core issues of trust and transparency in online gaming. Our integration of Chainlink VRF for provably fair outcomes is a significant achievement. Moreover, building a seamless and engaging user interface while maintaining robust security measures is an accomplishment we take great pride in.
What we learned
Through this project, we learned a lot about the intricacies of blockchain technology, especially in the context of smart contracts and decentralized oracles. We gained valuable experience in integrating Chainlink VRF and handling the challenges of maintaining transparency and security in a decentralized application. Additionally, we honed our skills in front-end development and user experience design.
What's next for Wager Wheels
The next step for Wager Wheels is to expand range of games and further enhance the platform's user experience. We plan to add betting games on platform to reach wider audiences and aim to implement more advanced security features and explore partnerships with other blockchain projects to continuously improve the fairness and transparency of our gaming platform.
Contract Address : 0x3703Eb845D675F5b3ebf18B323bb39b4cfB789CD
Built With
- alchemyapi
- chainlink
- netlify
- nextjs
- sepolia
- solidity
- vrf
- web3
Log in or sign up for Devpost to join the conversation.