Inspiration
Inspired by Minesweeper and smart contracts.
What it does
It is essentially a betting game, where you pay a set amount of AE coins to reveal each tile of the dungeon. You have a chance of winning more AE if you land upon a treasure tile, or, you risk losing the coins you spent if you encounter a monster and your game ends.
How we built it
We have 2 parties in this game, the player and the treasury. For our purposes, we have a fixed treasury (hard-coded public and private key of a wallet). The player can be anyone as long as they have the Superhero Wallet Chrome extension with a aeternity wallet linked to it.
We set up 4 smart contracts at the start of the game, set_treasury , set_reveal_fee , set_reward_amount , set_treasures . These contracts help us facilitate the game on the blockchain, so the state of the game is secure and cannot be changed after the initialization.
We use the smart contract function reveal to pay a certain amount of AE coins to the treasury to know the state of the tile. The tile can be one of 3 states: Empty, Treasure, Monster. Empty - nothing happens; Treasure - you are rewarded some AE coins; Monster - your game gets over.
We initialize two AEppSDK instances, one for the player, and one for the treasury at App launch. The treasury instance starts a smart contract named treasury_payout . This smart contract is used to give out the reward to the player.
Challenges we ran into
We ran into various problems at each implementation stage. We spent a lot of time figuring out the proper way and versions to make the wallet extension work. The most challenging part was writing the smart contracts. The syntax felt a bit fragile, there was a lot of code breaking while making changes to it.
Accomplishments that we're proud of
We actually made a risk-reward based game, which is a pretty fun. We made good use of smart contracts to ensure the game works as intended on the blockchain.
What we learned
We learned about the aeternity block chain, we learned about programming in Sophia and making smart contracts.
What's next for Aeternity Dungeon
We will make the game more secure, there are some oversights we made while designing the game. There are definitely various exploits which can be done on the client side.
Built With
- blockchain
- javascript
- sophia
- vite
Log in or sign up for Devpost to join the conversation.