November 2018
Intermediate to advanced
528 pages
13h 21m
English
As our main data repository, we will use a mapping structure to index all enrolled players using their address. If you remember, in the previous chapter, Peer-to-Peer Auctions in Ethereum we learned that a mapping is similar to a big key-value database with all possible key values filled with zeros.
In the tontine.sol file, add the following code:
pragma solidity ^0.4.24;contract Cplayer{ struct player{ string name; uint PhoneNumber; address Paddress; uint id; } mapping(address => player) players;}The code is pretty self-explanatory: we declare a new type called player, which is a structure (struct) that represents a user’s details.
We also declare a players mapping to store the users' details. In the mapping definition ...
Read now
Unlock full access