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
# Players.hpp | |
//@abi action | |
void addability(const account_name account, string& ability); | |
# Players.cpp | |
void Players::addability(const account_name account, string& ability) { | |
require_auth(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
//@abi table player i64 | |
struct player { | |
uint64_t account_name; | |
string username; | |
uint64_t level; | |
int64_t health_points = 1000; | |
int64_t energy_points = 1000; | |
vector<string> abilities; // This is our new property | |
uint64_t primary_key() const { return account_name; } |
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
# cleos push action {account} {action_name} '{data}' -p {account}@active | |
cleos push action anorak add '["wade","parzival"]' -p wade@active | |
executed transaction: dbd220f6a0b2cae4c216cb5a78bddd9dc50f0678424cc13d41a86b1f375731c8 112 bytes 386 us | |
# anorak <= anorak::add {"account":"wade","username":"parzival"} | |
cleos push action anorak getplayer '["wade"]' -p wade@active | |
executed transaction: 93d74d8ff08d5984ee197447409ffe10dad3855ae000431709d575035d74d3a3 104 bytes 431 us | |
# anorak <= anorak::getplayer {"account":"wade"} | |
>> Username: parzival Level: 1 Health: 1000 Energy: 1000 |
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
$ cleos wallet unlock -n {wallet_name} --password {password} |
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
# cleos set contract {account} {path_to_contract_folder} {path_to_.wast_file} {path_to_.abi_file} | |
cleos set contract anorak ./contracts/Players ./contracts/Players/Players.wast ./contracts/Players/Players.abi |
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
# recovers reversible block database if that database is in a bad state | |
--fix-reversible-blocks | |
# do not skip any checks that can be skipped while replaying irreversible blocks | |
--force-all-checks | |
# clear chain state database and replay all blocks | |
--replay-blockchain | |
# clear chain state database, recover as many blocks as possible from the block log, and then replay those blocks |
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" | |
namespace Oasis { | |
void Players::add(account_name account, string& username) { | |
// Action implementation body | |
} | |
void Players::update(account_name account, uint64_t level, int64_t healthPoints, int64_t energyPoints) { | |
// Action implementation body | |
} |
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 <eosiolib/eosio.hpp> | |
#include <eosiolib/print.hpp> | |
#include <string> | |
namespace Oasis { | |
using namespace eosio; | |
using std::string; | |
class Players : public contract { | |
using contract::contract; |
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
echo "Current working directory -" $1 | |
cd $1 | |
eosiocpp -g $2.abi $2.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
# Create a build folder if it doesn't exist | |
mkdir -p build | |
# Change the current directory to "build" | |
cd build | |
# Create all the build files needed | |
cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug .. | |
# Build |