Skip to content

Instantly share code, notes, and snippets.

Avatar

John X johnX9

View GitHub Profile
View create_robot.sh
cleos push action weyland1 create '{"account":"weyland1","newRobot":{"series_number":14441993,"model":"A330","operating_system":"DX42","profession":"engineer","owner":"","manufactured":0}}' -p weyland1
executed transaction: 5f45b48877aac9d03172616a2443b7a9079ee9f74a124a0976d2fcf0b756e985 176 bytes 2722 us
# weyland1 <= weyland1::create {"account":"weyland1","newRobot":{"series_number":14441993,"model":"A330","operating_system":"DX42",...
# market <= market::forsale {"account":"weyland1","robotForSale":{"series_number":14441993,"model":"A330","manufactured":0}}
# No notification for printmessage action
View RobotFactory.cpp
void RobotFactory::create(account_name account, robot newRobot) {
robotIndex robots(_self, _self);
auto iterator = robots.find(newRobot.series_number);
eosio_assert(iterator == robots.end(), "Robot with this series number already exists");
robots.emplace(account, [&](auto& robot) {
robot.series_number = newRobot.series_number;
robot.model = newRobot.model;
robot.operating_system = newRobot.operating_system;
View create_robot.sh
cleos push action weyland create '{"account":"weyland","newRobot":{"series_number":14441992,"model":"A330","operating_system":"DX42","profession":"engineer","owner":"","manufactured":0}}' -p weyland
executed transaction: 9874a8a5f516ca540c44cafd8b9b371c856fe7958be1fc6268641cc7ab67fdaf 136 bytes 6000 us
# weyland <= weyland::create {"account":"weyland","newRobot":{"series_number":14441992,"model":"A330","operating_system":"DX42",...
# market <= market::forsale {"account":"weyland","robotForSale":{"series_number":14441992,"model":"A330","manufactured":0}}
# messenger <= messenger::printmessage {"message":"A330"}
>> ==== For sale | Robot model: A330
View RobotFactory.cpp
void RobotFactory::create(account_name account, robot newRobot) {
robotIndex robots(_self, _self);
auto iterator = robots.find(newRobot.series_number);
eosio_assert(iterator == robots.end(), "Robot with this series number already exists");
robots.emplace(account, [&](auto& robot) {
robot.series_number = newRobot.series_number;
robot.model = newRobot.model;
robot.operating_system = newRobot.operating_system;
View RobotFactory.cpp
void RobotFactory::create(account_name account, robot newRobot) {
robotIndex robots(_self, _self);
auto iterator = robots.find(newRobot.series_number);
eosio_assert(iterator == robots.end(), "Robot with this series number already exists");
robots.emplace(account, [&](auto& robot) {
robot.series_number = newRobot.series_number;
robot.model = newRobot.model;
robot.operating_system = newRobot.operating_system;
View update_get_player.sh
if (currentPlayer.inventory.size() > 0) {
print(" Items: ");
for (uint32_t i = 0; i < currentPlayer.inventory.size(); i++) {
item currentItem = currentPlayer.inventory.at(i);
print(currentItem.name.c_str(), " == ");
}
} else {
print(" Empty inventory");
}
View player_items.sh
cleos push action anorak getplayer '["wade"]' -p wade@active
executed transaction: 170ef809509f1110b4d56fb910e6b946b1500b7f1fbb0825435596a06068f76b 104 bytes 835 us
# anorak <= anorak::getplayer {"account":"wade"}
>> Username: parzival Level: 4 Health: 1010 Energy: 1120 Abilities: see the future Items: magic ball ==
View buy_product.sh
# Buy product from Marketplace
cleos push action market buy '["wade",1]' -p wade
executed transaction: 804d430747459c309a9489ecd0f1c155f819788a0b270bcbf299d1222850b1dc 112 bytes 2253 us
# market <= market::buy {"buyer":"wade","productId":1}
# anorak <= anorak::transfer "000000004073e934000000006405af919600000000000000044f41530000000000"
# anorak <= anorak::additem {"account":"wade","purchased_item":{"item_id":1,"name":"magic ball","power":120,"health":10,"abili...
>> Item Id: 1 | Name: magic ball | Power: 120 | Health: 10 | Ability: see the future | Level up: 3
View add_products.sh
# Magic ball
cleos push action market add '{"account":"market","newProduct":{"product_id":1,"name":"magic ball","power":120,"health":10,"ability":"see the future","level_up":3,"quantity":10,"price":150}}' -p market@active
executed transaction: effdd4505745f336170dfdd1ab0e4579b7b578fada0273617de1c8204c042208 176 bytes 542 us
# market <= market::add {"account":"market","newProduct":{"product_id":1,"name":"magic ball","power":120,"health":10,"abilit...
cleos push action market getbyid '[1]' -p market
executed transaction: bd10a266a494919a578bc00cbaa73e0bbed52ad5d072fcca7b52d687c24e9367 104 bytes 618 us
# market <= market::getbyid {"productId":1}
>> Id: 1 | Name: magic ball | Power: 120 | Health: 10 | Ability: see the future | Level up: 3 | Quantity: 10 | Price: 150
View issue_tokens.sh
# Issue tokens to account anorak
cleos push action anorak issue '{"to":"anorak","quantity":"5000.0000 OAS","memo":""}' -p anorak
executed transaction: a16724e02577178dbf1c2fab5cad17f84d5e790a8ebf29dabdb273b4babd948c 120 bytes 497 us
# anorak <= anorak::issue {"to":"anorak","quantity":"5000.0000 OAS","memo":""}
#Issue tokens to account wade
cleos push action anorak issue '{"to":"wade","quantity":"5000.0000 OAS","memo":""}' -p anorak
executed transaction: ca11594c408def8fe7be5be7971b8264d4db6be941e743819f55f1c704b77f3c 120 bytes 1300 us
# anorak <= anorak::issue {"to":"wade","quantity":"5000.0000 OAS","memo":""}
# anorak <= anorak::transfer {"from":"anorak","to":"wade","quantity":"5000.0000 OAS","memo":""}
You can’t perform that action at this time.