/ eos

EOS Dev Guide 0x02

pre-requisite

This part assumes you've booted up the private net(nodeos) and had it kept producing blocks.
If not, please check the previous post: EOS Dev Guide 0x01.

Deploy eosio.bios contract

This step needs nodeos to be running and producing blocks.

We need to deploy eosio.bios to act as a system contract.

If you don't deploy this contract, you'll get error when you create accounts in following procedures.

According to official tutorial, it 'enables you to have direct control over the resource allocation of other accounts and to access other privileged API calls. In a public blockchain, this contract will manage the staking and unstaking of tokens to reserve bandwidth for CPU and network activity, and memory for contracts.'

The contract sits under eos/build/contracts/eosio.bios.

$ cd /path/to/eos/root/dir
$ cleos set contract eosio build/contracts/eosio.bios -p eosio

-p eosio means tell cleos to sign this transaction with the active authority private key of account eosio.

NOTE: Remember to have nodeos running and producing blocks, otherwise you'll get this:

Reading WAST/WASM from build/contracts/eosio.bios/eosio.bios.wasm...
Using already assembled WASM...
Publishing contract...
Failed to connect to nodeos at http://localhost:8888/; is nodeos running?

about restarting nodeos

Please check the previous post: EOS Dev Guide 0x01.

result of deploy contract

If things went smoothly as it should be, you'll get this output:

Reading WAST/WASM from build/contracts/eosio.bios/eosio.bios.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: 5280349864db00d70c41a58ce45b8beba3b98b7fcddf6a5fbc39995a6a6eeece  3712 bytes  4061 us
#         eosio <= eosio::setcode               {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001621260037f7e7f0060057f7e7e7e7e...
#         eosio <= eosio::setabi                {"account":"eosio","abi":"0e656f73696f3a3a6162692f312e30050c6163636f756e745f6e616d65046e616d650f7065...

you'll notice that one of the block produced has one transaction, which is the deploy tx.

Create accounts

Every account has two pairs of key to represent active and owner authorities. Each pair contains private key and public key.

Thus, in the product environment we need to generate two key pairs to support security feature.

NOTE: But for our test purpose, here we use the same for the two authorities:

create key pair

This step does not affect any states.

$ cleos create key
Private key: 5KUq25eiZHULak7eqne7UQgCE1WABvbVdDJ2NdJdbQ1Bw5bhS1x
Public key: EOS6U1QS4WEntL4hSnWtUxut77LUULecREFXYem9FxVwAQKoWGX94

import key pair

This step only affects local wallet.

use private key here:

$ cleos wallet import 5KUq25eiZHULak7eqne7UQgCE1WABvbVdDJ2NdJdbQ1Bw5bhS1x
imported private key for: EOS6U1QS4WEntL4hSnWtUxut77LUULecREFXYem9FxVwAQKoWGX94

create account

This step needs nodeos to be running and producing blocks.

use public key here.
use the same public key twice as the reason we stated above.
(first is owner public key, then active public key)

$ cleos create account eosio user EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
executed transaction: 8aedb926cc1ca31642ada8daf4350833c95cbe98b869230f44da76d70f6d6242  364 bytes  1000 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"user","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7DJxentZZ...

We can import another account:

$ cleos create account eosio tester EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
executed transaction: 414cf0dc7740d22474992779b2416b0eabdbc91522c16521307dd682051af083 366 bytes  1000 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"tester","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7DJxentZZ...

According to the EOS official guide, 'Because we are using the eosio::history_api_plugin we can query all accounts that are controlled by our key:'

$ cleos get accounts EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
{
  "account_names": [
    "tester",
    "user"
  ]
}

check user status

$ cleos get account user

End

That's it for this post, see you soon.

patient

EOS Dev Guide 0x02
Share this