Skip to content

Instantly share code, notes, and snippets.

View johnX9's full-sized avatar

John X johnX9

  • @infiniteXLabs
View GitHub Profile
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include <string>
# 1. Create new wallet with the name "oasis"
cleos wallet create -n oasis
# 2. Generate two pair of keys (use the command twice)
cleos create key
# 3. Import the generated private keys in the wallet(you need to specify the wallet at the end)
# {private_key_1} - This will be the OwnerKey
# {private_key_2} - This will be the ActiveKey
cleos wallet import --private-key={private_key_1} -n oasis
# To print contract's output to console by default add:
# --contracts-console
nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --contracts-console
# 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
#include "Players.hpp"
namespace Oasis {
using namespace eosio;
using std::string;
class Players : public contract {
using contract::contract;
public:
#include "Players.hpp"
namespace Oasis {
using namespace eosio;
using std::string;
}
//@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; }
EOSLIB_SERIALIZE(player, (account_name)(username)(level)(health_points)(energy_points))
EOSIO_ABI(Players, (add)(update)(health)(energy)(getplayer))
// EOSIO_ABI(class_name, (action_1)(action_2)(action_3)...(action_n))