sudo nano ~/.local/share/eosio/nodeos/config/config.ini
- Change the
http-server-address
to0.0.0.0:8888
sudo nano ~/.bash_aliases
- Add a
#
in front of thecleos
alias we set up before, we will no longer use it - restart
nodeos
cd ~
mkdir scripts
cd scripts
nano comptract.sh
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "USAGE: comptract.sh <ACCOUNT NAME> <Contract Name> from within the directory"
exit 1
fi
ACCOUNT=$1
CONTRACT=$2
eosiocpp -o ${CONTRACT}.wast ${CONTRACT}.cpp &&
eosiocpp -g ${CONTRACT}.abi ${CONTRACT}.cpp &&
cleos set contract ${ACCOUNT} ../${CONTRACT}
chmod +x comptract.sh
- Add
export PATH=$PATH:~/scripts
to the end of your~/.profile
file export PATH=$PATH:~/scripts
cleos create account eosio basics <PUBLIC KEY> <PUBLIC KEY>
- Make a new directory inside of your
shared_contracts
folder calledtutorials
and then another inside of that calledbasics
- Create a new cpp file called
basics.cpp
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
using namespace eosio;
using namespace std;
class basics : public contract {
using contract::contract;
public:
basics( account_name self ) :
contract(self),
_statuses(_self, _self){}
// @abi action
void test( name sender, string status ){
require_auth(sender);
auto iter = _statuses.find(sender);
if(iter == _statuses.end()) _statuses.emplace( sender, [&]( auto& row) {
row.sender = sender;
row.status = status;
});
else _statuses.modify( iter, 0, [&]( auto& row) {
row.status = status;
});
}
private:
// @abi table
struct statuses {
name sender;
string status;
name primary_key() const { return sender; }
EOSLIB_SERIALIZE( statuses, (sender)(status) )
};
multi_index<N(statuses), statuses> _statuses;
};
EOSIO_ABI( basics, (test) )
cd /media/sf_shared_contracts/tutorials/basics/
comptract.sh basics basics
cleos push action basics test '["asdf"]' -p eosio
cleos push action basics test '["eosio", "Hello World"]' -p eosio