All articles

How to Build a DApp Game App Like CryptoKitties?

How to Build a DApp Game App Like CryptoKitties?

Interested in building a hospital mobile app? 

That’s an excellent market with many opportunities to be explored.

According to a study, “total revenue in 2018 was a whopping $ 13.55 billion. With a compound annual growth rate (CAGR) of 2.8%, it should reach $ 15.138 billion in 2022.” 

Besides the huge sums to be made, innovating in this industry is a great way to help improve people’s lives. Here’re a few amazing case studies of companies who hired DevTeam.Space to build their software products:

  1. Swift Gift– eCommerce Android and iOS App
  2. Face, Sex, Age, Recognition System – Machine Learning Program
  3. Alibra – Mobile App Video Streaming Solution


What is CryptoKitties?
Are there ready-made tools to develop a DApp game app?
Build an Ethereum game with Loom Unity SDK:
Code your own crypto game from scratch:
Build your crypto game app development team:
Learn Ethereum DApp development skills:
Create an Ethereum account for your DApp:
Install DApp development tools:
Review CryptoKitties smart contracts:
Code smart contracts for your decentralized application:
Test, deploy and run your smart contracts:

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 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 pay others to breed their kittens with other players‘ kittens. Players can also advertise their kittens for sale.

The smart contract code in the game controls attributes of kittens, and in some cases breeding would result into a rare breed of kittens. These commanded higher prices.

At the time of writing this, total sales amount to $ 25 million! If you are in the market for digital kittens, then you can track these sales via this third-party website.

Interestingly, the success of this game managed to slow down the Ethereum network considerably in December 2017. This sparked a huge debate into the limited scalability of blockchain networks.

Are there ready-made tools to develop a DApp game app?

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 blockchain-based apps. 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 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:

A screenshot from CryptoKitties

Loom Unity SDK enables you to quickly start your DApp game 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 write, and input your private and public key 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 ’play‘ option, click on it and see your open-sourced DApp game 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 game app from the ground up, however, it’s a more complex project. You need to do the following:

  1. Build a capable team;
  2. Learn the necessary skills;
  3. Create your Ethereum account;
  4. Install the necessary tools;
  5. Review smart contracts for similar games;
  6. Code smart contracts;
  7. 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:

  1. UI/UX design;
  2. Ethereum DApp and smart contract development;
  3. Testing;
  4. Project management with blockchain development project experience.

Ethereum DApp and smart contract development are niche skills, and sourcing a project manager with blockchain development track record could be hard. Get professional help from blockchain development companies if you can‘t source 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. 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:

  1. Ethereum development: Check out the “Ethereum Development Tutorial” on GitHub.
  2. 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, they get a hands-on experience.

Create an Ethereum account for your DApp:

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 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 the tool to communicate with blockchain. After installing it, you need to configure ’aconfig.js’ file. Also, configure their web APIs to communicate with 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, 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:

  • KittyAccessControl: This is for management control. The code has special roles, for 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, for 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. 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. That 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 application:

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 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 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, besides 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 to create a DApp game app. Check out examples of similar Ethereum DApp games:

  1. 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.
  2. Etheremon: You can capture virtual monsters or trade in them.

Frequently Asked Questions

What is a DApp?

DApp stands for Decentralized Application. They are apps that operate on a network for decentralized computers via blockchain technology.

Where to find blockchain developers?

You can find expert blockchain developers in the DevTeam.Space community. The platform has extensive experience developing blockchain-based solutions.

How much money does CryptoKitties make?

CryptoKitties recorded $12 million in sales at the end of 2017. This figure has risen significantly in recent years.


Hire Expert Developers

DevTeam.Space is a vetted community of expert dev teams supported by an AI-powered agile process.

Companies like Samsung, Airbus, NEC, and startups rely on us to build great online products. We can help you too, by enabling you to hire and effortlessly manage expert developers.

LinkedIn LinkedIn Facebook Facebook Twitter Twitter Facebook Messenger Facebook Messenger Whatsapp Whatsapp Skype Skype Telegram Telegram