- Create a game contract with a target compiler version. We will use version 0.4.23 for this specific contract. This contract acts as a database to store our hero details and a battle arena where heroes can fight against each other:
pragma solidity ^0.4.23;contract HeroBattle { //...}
- Create a hero data structure with name, DNA, level, win count, and loss count. Each hero will have a DNA number. Just like human DNA, each part of this number denotes different traits of a hero. For example, the first two digit map to the hero's looks, the second two digits maps to the flying ability, and so on. This can be configured in your game UI:
struct Hero { string name; uint dna; uint32 level; uint16 winCount; uint16 lossCount;} Hero[] ...