Inspiration

We were three developers who wanted to create a project to learn and start their journey in blockchain development. We were into games like Animal Crossing and Pokemon since we were kids, that's where the idea of developing this project came from. The project is a bit of a mixture of the two. It features battles of creatures and the creation and decoration of your island. To make it a play-to-earn game, we designed a DeFi part consisting of a decentralized exchange, a vault, and much more. Over time the project went from being just a side project to learn Solidity and blockchain technologies to a big project deployed on mainnet.

What it does

Space Pirates is a play-to-earn game of pirates flying and plundering in an imaginary space with galleons. Users can create their team of fighting creatures, explore islands and meet fellow pirates. Conquer a land on a floating island and settle down your base, place down all your furniture and your decorations and create your home following your taste. Invite your friend to visit your place and chill together. Do friendly battles to show your best creatures’ attack combos. Collect all the items around space: decorations for your island and galleon, gadgets to power up your creatures, and more.Obtain the rarest title in the galaxy and be the most famous pirate.

Let’s pirate!

Detailed information about Space Pirates in the documentation.

How we built it

We wrote the smart contracts using Solidity and Hardhat to test and prove the contracts locally most easily and simply possible. To deploy on-chain, we opted for Tronbox and TronWeb. TronBox was used to compile the contracts and generate the artifacts. TronWeb to deploy the contracts and execute the setup transactions. Initially, we tried to use TronIde but, due to the multitude of contracts and the setup transactions, we decided to switch to Tronbox and TronWeb to automate the process and reduce the possibility of errors. Regarding the frontend, we used TypeScript with Next.js and TailwindCSS. Next.js allowed us to select how to render pages (i.e., server-side, static, or client-side) and improve SEO and general performances. TailwindCSS is one of the CSS libraries with the shortest time to production. We developed a clean and consistent UI rapidly reusing a lot of components.

Challenges we ran into

Tokens

The first challenge we had was deciding how to manage the project tokens. Given the fact that the game would have so many tokens and so many NFTs (e.g., object decorations, titles, and more), we decided to implement it all in an adapted ERC1155 contract. Such a contract allowed us to keep all the tokens on a single contract making it easier to manage and exchange them. We also added the ability to add new tokens and chose ID ranges for each token category (e.g., titles, decorations, items, battlefields). Moreover, to give the ability to add and remove implementations, we opted for a module approach. We preferred this approach to a proxy contract that would have had the problem of reloading the complete new contract each time. The central contract keeps track of the permissions on tokens thanks to AccessControl. Such a pattern allows for managing permissions, like minting and burning, to individual implementations (i.e., individual contracts).

Mint and burn roles by categories

Initially, the minting and burning roles were calculated dynamically. This means that an individual token had a dedicated mint-burn role. The problem showed itself when we had contracts such as marketplace that needed to mint tokens of multiple categories. Hence, giving roles for, let's say, 1000 IDs would have been unthinkable. That is why we created specific roles to permit the minting and/or burning of the categories. To mint or burn a token you need either the role of the respective category or the dynamically generated role for the individual token.

Quest

To verify the completion of quests, we decided to adapt the EIP712 standard. The problem we found is that Tron does not talk anywhere about the chainId parameter and whether it was implemented and what it was. To solve this problem, we created a support contract that, once deployed, saves a value in a public variable on-chain so that it was possible to access it. Another problem encountered was how Tron handles addresses with ECDSA recovery. After several attempts, we found that the address calculated with recover is of standard EVM, so the same as Tron converted to hex but without the prefix of 41.

URI

Another difficult decision was about whether to keep the metadata of the tokens/NFTs on a decentralized infrastructure (e.g., IPFS) or on a centralized one. The centralized solution was convenient because the NFTs metadata is updated frequently and is easier to set up. So, for now, we have opted for a centralized solution, intending to move to a decentralized infrastructure in the future.

Governance

The application of the vote-weighted system required that two parameters were constant to avoid vote manipulation: user balances and the number of users. For this reason, we decided that ve-Asteroids cannot be locked during active proposals. However, you can still unlock locked tokens since it does not induce possible manipulation in your favor. Users count and balances will be saved at the beginning of the proposal and will be used for calculations.

Accomplishments that we're proud of

We are proud of the fact that we managed to devise the whole ecosystem and develop all the major parts just in 3 and with little time. We are also excited about the fact that we managed to create a system of weights that prevents too much centralization of power in governance by giving more weight to small token holders. We are also very pleased that our project got a code contribution from outside. We love open-source projects.

What we learned

We learned a lot about teamwork. We started the project as colleagues and now we are friends. We also learned a lot about Solidity and blockchain development. There is no better way than learning through building real products. Moreover, as we designed the whole game, we learned about game design and tokenomics. Building an innovative product for Tron Grand Hackaton was a wonderful experience. We hope it's just the beginning of a big journey!

What's next for Space Pirates.

Space pirates by no means end here. We're just getting started! We have a roadmap full of additions to develop to complete the project. The first step is to strengthen the project core and deploy it in the testnet. The goal of deploying in testnet is to create a community that can start testing our product and give us feedback. Moreover, this step can help us in building a vast community of people eager to play the game. The testnet phase will also be used to assess the stability of the system: bug bounties will be available for users that find bugs in our code. Bug discoverer will be rewarded with the project tokens and an in-game title at launch. In the meantime, we will focus on the development of the NFT collections from the graphical point of view. Once the entire ecosystem has been fully tested and contract audits have been received, the protocol will be ready to be launched in the mainnet. All the players that helped us in exploring and testing the protocol will be rewarded with an airdrop of the initial tokens. The more players have interacted with the protocol in testnet, the more rewards they will receive in airdrops. Once this is published, our adventure will not be over there. We have much more planned to develop, such as the NFTs Rent contract, PvP tournaments, the Single-player campaign, the Kingdoms (i.e., kingdoms of players), and the Dungeons. Another key part of the game will be the events offered throughout the year. In addition to celebrating the holidays with players, there will be more narrowly focused events like themed land decoration competitions. The possibilities for expansion are endless. For this reason, we created the various contracts as flexible as possible to change so that it will always be possible to create new in-game activities. In addition, all updates will be offered for a trial period always in testnet to gather the players feedback.

Contacts

Built With

Share this project:

Updates