Skip to content

Instantly share code, notes, and snippets.

View johnX9's full-sized avatar

John X johnX9

  • @infiniteXLabs
View GitHub Profile
#include "Players.hpp"
namespace Oasis {
using namespace eosio;
using std::string;
class Players : public contract {
using contract::contract;
public:
// EOSIO_ABI(class_name, (action_1)(action_2)(action_3)...(action_n))
EOSLIB_SERIALIZE(player, (account_name)(username)(level)(health_points)(energy_points))
EOSIO_ABI(Players, (add)(update)(health)(energy)(getplayer))
eosiocpp -o Players.wast Players.cpp
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
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;
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
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;
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;
cd ~/eos/build/programs/cleos/
# Outputs a password that you need to save to be able to lock/unlock the wallet
# If you don't want to use the "default" wallet add: -n {your_wallet_name} at the end of your command
cleos wallet create