- How to Build DApp Games Like CryptoKitties?
We hope you enjoy reading this article.
If you want our expert developers and designers to work on your online product, click here
Latest posts by Aran Davies (see all)
- How To Build a Distributed System? - 28 May, 2023
- How to Create An AI Crypto Trading Bot? - 23 May, 2023
- What Is an Initial Coin Offering? - 22 May, 2023
Interested in knowing how to build DApp games?
That’s an excellent market for the gaming industry with many opportunities to be explored.
What is CryptoKitties?
It‘s an online game that runs on the Ethereum blockchain. Axiom Zen, a Vancouver, Canada-based company launched it on November 28th, 2017. It quickly went viral.
The game involves a play-to-earn model of buying, selling, and breeding digital kittens. It runs on the Ethereum blockchain network and allows players to pay with its‘ native cryptocurrency Ether (ETH). It‘s a distributed app (DApp).
By December 6th, 2017, players of CryptoKitties had already spent an incredible $ 6.7 million on this game! Some kittens commanded a price of 50 ETH, i.e. US $ 23,000. The ’genesis kittens‘, i.e. the first batch of kittens, had a price tag of 246 ETH, i.e. US $ 113,000!
The creators started the game with 100 ’founder kitties’, and the game released a new ’gen 0′ kitten every 15 minutes. The creators put the first set of kittens in an auction, and people bought them like crazy. Players also resold kittens.
Players could put their kittens up for breeding. They get paid in ETH for this, and they paid others to breed their kittens with other players‘ kittens. Players could also advertise their kittens for sale.
The smart contract code in the game controlled the attributes of kittens, and in some cases breeding would result in a rare breed of kittens. These commanded higher prices.
The total sales amount to $184,281.03 and the market for digital kittens is still up and running. You can track these sales via this website.
Interestingly, the success of this game managed to slow down the Ethereum network considerably in December 2017. This sparked a huge debate about the limited scalability of blockchain networks.
Hire expert developers for your next project
Are there ready-made tools to build DApp Games?
The Loom Network is a start-up that offers ’Platform as a Service (PaaS) for building DApps on the Ethereum blockchain. They have created tools to build large-scale apps for blockchain use cases.
If you are trying to build online games and social apps on the Ethereum blockchain, then you will find their software development kits (SDKs) quite useful.
Their SDKs allow you to build your DApp game app on sidechains called ’DAppChains‘. These can help to make your DApp games more scalable.
Read more about it in “Million-User DApps on Ethereum: An introduction to Application-Specific Sidechains”.
Using sidechains allows you to customize rules for your DApp. For e.g. if it‘s just a social app requiring lower security, you can choose to use the ’proof of stake‘ (PoS) consensus algorithm instead of the energy-intensive ’proof of work‘ (POW).
Read more about how PoS can make your app more scalable in “Proof of Work vs Proof of Stake Comparison”.
Loom Network has an SDK that focuses on building online games, and it‘s called ’Unity SDK‘.
You can build a blockchain-based game app that will work on desktops like Mac, Windows, and Linux. The SDK also supports Android and iOS. Read more in the Unity SDK documentation on their website.
Build an Ethereum game with Loom Unity SDK:
Loom Unity SDK enables you to quickly start your DApp games app development. You can start with their sample code, which you can modify to suit your requirements. Find the sample code in the GitHub repository of Unity SDK.
- Connect to a DappChain using their ’contract‘ class. This way, you can interact with the smart contracts there. You need to write a method to create a ’contract‘ instance for this.
- To write data to a DappChain, send a signed transaction, and the DappChain will validate it. You can now call a specific public method to store an association between a key and a value.
- The ’contract’ class addresses the validation using another method. This allows changing the state of the smart contract and enables writing data.
- To read data from a DappChain, you need to invoke a public read-only method, which doesn‘t change the smart contract state. Again, there are already methods defined for you to use.
- Combine your code for reading and writing, and input your private and public keys according to instructions.
- Create an empty game object using the SDK and attach your script to it. Deploy your smart contract on a local Loom DappChain.
Unity SDK editor has a play option, click on it and see your open-sourced DApp games run! Read detailed instructions in the Unity SDK documentation on their website and their Unity3d SDK GitHub repository.
Code your own crypto game from scratch:
You can also code a DApp games app from the ground up, however, it’s a more complex project. You need to do the following:
- Build a capable team;
- Learn the necessary skills;
- Create your Ethereum account;
- Install the necessary tools;
- Review smart contracts for similar games;
- Code smart contracts;
- Test, deploy and run your smart contracts.
I have earlier described some of these steps in “How to Build Online Marketplace on Blockchain Like OpenBazaar?”, check it out.
Build your crypto game app development team:
You need the following skills in your team:
- UI/UX design;
- Ethereum DApp and smart contract development;
- Project management with blockchain development experience.
Ethereum DApp and smart contract development are niche skills, and sourcing a project manager with a blockchain development track record could be hard. Get professional help from blockchain game development companies if you can‘t source the required people.
Learn Ethereum DApp development skills:
The crypto-collectibles game you are about to build is a DApp, and the project team must understand the concept behind it.
A DApp game app can use any language for frontend code, but the backend code must comprise smart contracts and it must run on a decentralized blockchain.
It must run autonomously, and you can modify the open-source code only if you have a consensus from users.
Hire expert developers for your next project
1,200 top developers
us since 2016
It must use a crypto token created using standard cryptographic algorithms and must store data in a blockchain while following cryptographic standards. No user can control the majority of tokens.
Learn more about DApps in “What is a Decentralized Application?”.
Your team needs the following skills:
- Ethereum development: Check out the “Ethereum Development Tutorial” on GitHub.
- Solidity, i.e. the proprietary language of Ethereum to code smart contracts: You can use this Blockgeeks Solidity online course.
I also strongly recommend your team to take this fun, interactive CryptoZombies course by Loom Network. It‘s particularly suitable for beginners in blockchain game development as they get hands-on experience.
Create an Ethereum account to build your DApp Games App
You will code smart contracts, deploy them on Ethereum, and execute them as part of this project. You need Ether for this, hence you need to create an Ethereum account and wallet address.
There are two kinds of Ethereum accounts, and these are ’externally owned account’ (EOA), and contract account.
A person joining the Ethereum network needs EOA, whereas contract accounts hold smart contracts and are controlled by code. Read the Ethereum Development Tutorial in GitHub to know more about this.
Use ’eth-lightwallet, it‘s easy to use so you can easily create your private and public keys with it. Secure the private key, don‘t share it anywhere and with anyone.
Read the eth-lightwallet GitHub documentation for instructions.
Buy Ether, which you will use later.
Install DApp development tools:
You need to install the following tools:
- ’testrpc‘: It‘s a blockchain client that‘s straightforward to use. It has a command-line interface (CLI), and you need to set a block interval using it.
Note: The default setting is not to mine blocks. Use their GitHub instructions to install and configure it.
- ’web3js’: This is the tool to communicate with the blockchain. After installing it, you need to configure the ’aconfig.js’ file. Also, configure their web APIs to communicate with the blockchain.
Follow installation and configuration instructions in their GitHub repository.
- ’Truffle‘: It‘s an easy-to-use tool for testing and deploying smart contracts. It provides different folders for smart contracts, blends in easily with your testing framework, and makes deployment easy.
Check out their GitHub repository for installation and configuration instructions.
Open ’testrpc‘ and run an instance of it. Now, update your ’config.js‘ file with the private and public key information from your eth-lightwallet settings.
This allows you to communicate with the blockchain network. Read more about these steps in “Getting Started as an Ethereum Web Developer”.
Review CryptoKitties smart contracts:
This is an optional step. You may have already planned how your smart contracts will function. However, if you want to get some ideas from CryptoKitties smart contracts ecosystem, read this section, otherwise, skip to the next section.
View CryptoKitties source code in this EthFiddle repository. The code is modular and divided into several smaller smart contracts. Following is a brief overview of these:
Hire expert developers for your next project
- KittyAccessControl: This is for management control. The code has special roles, e.g. ’CEO‘, ’COO‘, and ’CFO‘. This contract defines a few functions for these roles only.
- KittyBase: This accomplishes multiple tasks. It specifies attributes for kittens, e.g. birth timestamp, genetic code, etc. This contract also serves as a database for all kittens and their ownership.
- KittyOwnership: This contract defines kittens as crypto tokens. These tokens follow ERC721 standards and are not fungible, meaning they are NFT. In the context of this game, it means that one kitten is never the same as another.
- KittyBreeding: The players use this when they put up their kittens for breeding.
- geneScience: This determines the genetic attributes of a newly born kitten. If players can see this, then they will plan how to breed their kittens to get a rare kitten, which will bring a higher price. This reduced the fun of the game. Hence, the creators have made this a closed-source code contract.
- KittyAuctions: The contract for buying, selling, and auctioning kittens.
- KittyMinting: This is the contract for creating ’gen 0‘ kittens. This was important because the creators had to give away new kittens to get the game started. There is a hard limit of 50,000 such kittens. The player community needs to breed their kittens to increase their number in this game.
- KittyCore: The main smart contract that combines everything together and runs on the Ethereum blockchain.
Note: All images of the kitten are stored in the central web server of this game, and they aren‘t in the Ethereum blockchain.
You can read a detailed review of CryptoKitties smart contracts in “How to Code Your Own CryptoKitties-Style Game on Ethereum”.
Code smart contracts for your decentralized applications:
While you develop your UI/UX for the game, you can code smart contracts in parallel. Smart contracts are pieces of code that use “IF-THEN-ELSE” logic, and transfer digital assets like cryptocurrencies from one account to another based on certain conditions.
Smart contract code is open-source, and you can‘t modify them after deployment.
In the Ethereum platform, you need to use Solidity language to code them. They are stored in the blockchain using contract accounts, which can‘t be tampered with.
Their execution is automatic, and the results must be visible in the blockchain. You also can‘t reverse the outcome of execution.
This means you need to exercise great care before you deploy them. Players will use their fiat currency to buy Ether so that they can play your game, and they may lose money if the code has bugs.
Keep smart contract logic as simple as possible. Code requiring high computation will need more Ether to execute, and chances of error are higher in complex code. Read more about smart contracts in “What is a Smart Contract?”.
Test, deploy and run your smart contracts:
You can use Truffle to test and deploy smart contracts. The deployment will require you to spend some Ethers, and you need to budget for miner fees.
Remember that you need to invoke smart contracts with hexadecimal strings. Ethereum has ’application binary interfaces’ (ABIs) to help with this, and you can access them in GitHub ABI libraries.
This completes your project of DApp game development. Check out examples of similar trending Ethereum DApp games:
- Ether Shrimp Farm: You can claim free shrimps that will lay eggs. You can hatch or sell the eggs. The game uses Ether for transactions.
- Etheremon: You can capture virtual monsters or trade in them.
Interested in DApp Games Development?
This is an exciting investment area for the gaming sector, given the popularity of blockchain technology applications in recent years. However, being an emerging technology, it requires a niche skillset to get started with.
If you, as a business CTO, are looking for expert DApp games developers, DevTeam.Space can help you. Do not miss a chance of partnering with experienced blockchain developers for your DApp game development project.
Write to us your initial requirements for your DApp project via this form and one of our technical managers will contact you for further discussion.
Frequently Asked Questions on DApp Games
DApp stands for Decentralized Application. They are apps that operate on a network of decentralized computers via blockchain technology.
You can find expert blockchain games developers in the DevTeam.Space community. The platform has extensive experience developing blockchain-based defi solutions. Fill out this form to get in touch with DevTeam.Space instantly and discuss your DApp project details.
Some other games using cryptocurrencies like Tron, eos, and eth are League of Kingdoms, CryptoBrewMaster, My Crypto Heroes, Axie Infinity, etc.