Bounty Bonanza game
Tags: blockchain, web3, gamedev, unity3d
Published: 2023-02-12 22:01:19

The majority of web3 games right now revolve about creating an in-game economy with its own tokens and NFT ecosystem. Creating a whole new economy for your game is very difficult and demands a really good team to create quality game NFTs, solid tokenomics and an engaging game that is fun to play. We took a different approach for this project and set aside tokens and NFTs for a moment.

We created a simple game leveraging some of the cool qualities that blockchain has to offer, those are: rewards and DeFi. The game itself is similar to Fruit Ninja. You have 60 seconds to destroy as much objects as you can but if you destroy the skull object 3 times is game over, destroying the skull also decreases your score.

Regarding to blockchain, the two main components of the game are:

- The bounty: is the sum of all the player’s entrance fee.
- The deadline: is the date until the players can participate in the game and after the winner can claim the prize.


![diagram-of-bounty-bonanza](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9sw3e0fqohixyr2hs52v.jpg)

In order to play you need to pay a certain amount of ETH (that goes straight to a bounty) and the player with the highest score can take it all after the deadline. We also integrated with AAVE V3 in Goerli so the bounty generates interest until the deadline.

This bounty-game format can be integrated with any game and can be used to achieve different objectives, for example:

- A teacher can use it to motivate his student to play a game when you have to solve math problems to advance and the top 3 students receive the money.
- A group of friends can use it to raise some funds and go to a trip.
- A charity project can change the logic of the smart contract and set that 50% of the game bounty goes to a charity and 50% to the winner.
- Different percentages of the bounty can be distributed when the game ends: 50% to the winner, 30% for the second place, 10% for the remaining players and 10% for the developers.

You can play the game in this [link](https://wildanvin.github.io/bounty-game-build/) and maybe you can claim the prize 😉... and this is the [github](https://github.com/namdar12/ReadyPlayer3Hackathon) repo.

## How we built it

We used Thirdweb unity SDK to add web3 functionality to Unity and ContractKit to deploy the contracts to Goerli testnet

## Challenges we ran into

Make the game available online: turns out that you need to enable **Decompression Fallback** so the game can be served from Github pages. Here is the [link](https://docs.unity3d.com/Manual/webgl-deploying.html)  that explains it.

The integrations with AAVE V3 in Goerli was kind of tricky because to deposit ETH you have to go through a contract called WETHGateway in order to deposit ETH. With other ERC20 the process is a bit more straight forward

In order to test new functionality with the blockchain we had to “build and run” which takes about 5 to 10 minutes, that was time consuming.

## Accomplishments that we're proud of

The integration with Aave and have the game “online” in github pages so everyone can play with it.

## What we learned

We have never made a game before and we learned a lot of Unity, C#, solidity and DeFi. Big thanks to Thirdweb and the tools developed by them like UnitySDK and ContractKit. These tools and SDKs really help to narrow the gap between technologies (like game development and blockchain) so is easier for developers to build cool stuff with them.

## What's next for Bounty Bonanza Game
- In the future we would like to make this a standard kit of contracts so any game developer can integrate this functionality into any game. It is very important also to improve the security of the contracts too.
- We want to add other wallet connections, so users can decide which wallet they want to connect with. 
- Use scenario.gg to generate prefabs and backgrouds.
- The winners can get a soul bound NFT with their high score.
- Add different levels to the game.
- Have users create their own mini bounites that they can share with their friends. 
- Have the background change each time a player plays. 

That is all from us, feel free to reach out if you have any questions or feedback: [Wilman](https://twitter.com/wildanvin) and [Namdar](https://twitter.com/NamdarMesri12)