This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the account using the public keys | |
cleos create account eosio anorak {public_OwnerKey} {public_ActiveKey} | |
# "eosio" is the name of the account who will create the new one | |
# "anorak" is the name of the new account |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Players.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Oasis { | |
using namespace eosio; | |
using std::string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EOSLIB_SERIALIZE(struct_name, (property_1)(property_2)(property_3)...(property_n)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// typedef multi_index<N(table_name), object_template_to_use> multi_index_name; | |
typedef multi_index<N(player), player> playerIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@abi table player i64 | |
struct player { | |
uint64_t account_name; | |
string username; | |
uint64_t level; | |
uint64_t health_points = 1000; | |
uint64_t energy_points = 1000; | |
uint64_t primary_key() const { return username; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@abi action | |
void add(const account_name account, string& username) { | |
/** | |
* We require that only the owner of an account can use this action | |
* or somebody with the account authorization | |
*/ | |
require_auth(account); | |
/** | |
* We access the "player" table as creating an object of type "playerIndex" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eosiocpp -g Players.abi Players.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@abi action | |
void getplayer(const account_name account) { | |
playerIndex players(_self, _self); | |
auto iterator = players.find(account); | |
eosio_assert(iterator != players.end(), "Address for account not found"); | |
/** | |
* The "get" function returns a constant reference to the object | |
* containing the specified secondary key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/eosio/eos --recursive |
OlderNewer