EOS is the new blockchain technology with much more advanced, dynamic and flexible features compared with the competent Ethereum. The founders of EOS claims that there will be no transaction fees for EOS blockchain. EOS also comes with a high scalability, enabling millions of transactions per second.

To know more about EOS, you can browse our previous blogs titled” Getting Started with EOS and EOS Blockchain”.

This is a simple, yet detailed tutorial for the beginners in EOS. With the directions cited below, one can easily understand the deployment of eosio.token contract





Step-1: Firstly, we need to create a wallet for storing the keys. One can skip this step if the wallet is already created.

$ cleos wallet create -n mywallet

password: PW5J7gbwLW3h3bTSv82vwQd7GA8vAqQ43WseWPkEpnyuJSvi47xs1

(“mywallet” is the name of the wallet. If a name is not defined wallet name will be “default” by default)

Following the action above, a password is generated for the created wallet. One should save them in confidentiality for future purposes.

The wallet will get automatically locked in regular intervals. Use the command below for unlocking your wallet.

$ cleos wallet unlock -n mywallet

Then you have to enter the password to unlock the wallet





Step-2: Creating keys is the next step.

$ cleos create key





Output:

Private key: 5JeqePJPzek6g7ggx7UV9yfbQz2o3P2udAUZAu7sF9NM5rseVVm

Public key: EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3

A pair of private key and public key will be generated. A private key is something like a pin number of your ATM card, therefore keep them highly confidential.

Meanwhile, a public key is like an account number of your bank account. You can share them with others whenever the purpose comes by.





Step-3: Now import these keys into your wallet using your private key

$ cleos wallet import 5JeqePJPzek6g7ggx7UV9yfbQz2o3P2udAUZAu7sF9NM5rseVVm

Output:

imported private key for: EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3

If you skip this step, you will lose control over your accounts. Because keys will not be automatically imported into the wallet





Step-4: Create two accounts “user” and “tester” using the above generated public key. These accounts will be used later.

$ cleos create account eosio user EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3 EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3

(Account “user” created using the public key)

$ cleos create account eosio tester EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3 EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3

(Account “tester” created)





Step-5 For deploying the contract, one has to create another account. Here we are creating an account named "acc"

$ cleos create account eosio acc EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3 EOS8LThdyVD95mgQXhkFDBmsmQppGZCnp8ZAwZpMUVQ8xYo5WPJN3





Step-6: Then set the contract eosio.token into the account acc

$ cleos set contract acc build/contracts/eosio.token -p acc

“build/contracts/eosio.token” is the path which contract exists (Assuming current directory is at eos/). Always make sure that the path provided is correct.

Otherwise, it will not work. “-p acc” is for setting permission from account acc.

Here the "eosio.token" contract is set with the account "acc". Now we can use the acc account for performing actions of eosio.token contract





Step-7: Now we are all set to manipulate the contract eosio.token. Every contract consists of some functions. These functions are called actions.

Our next step is to push the actions in order to perform particular functions. While going through the cpp file of eosio.token we can see three functions as below

void create( account_name issuer,asset maximum_supply );

void issue( account_name to, asset quantity, string memo );

void transfer( account_name from,account_name to,asset quantity, string memo );

There are three main functions- create, issue and transfer. In this step create action is described, remaining will be explained in upcoming steps.

$ cleos push action acc create '[ "eosio","1000000000.0000 CYBRO"]' -p acc

By this command, we have created 1000000000 CYBRO tokens. The account name of the issuer is eosio.

You don’t have to create the account eosio. It is a privileged account.

Step-8 We have now 1000000000 CYBRO tokens. Let’s issue some of them to the account “user”

$ cleos push action acc issue '[ "user", "1100.0000 CYBRO", "memo" ]' -p eosio

Here we are issuing 1100 CYBRO tokens to an account called user.

acc is the account which contract is set. the user is the recipient account eosio is the account with issuing authority.

So we are accessing permission from privileged account eosio for issuing the tokens

You can check the balance of the account user

$ cleos get table acc user accounts

output:

{

"rows": [{

"balance": "1100.0000 CYBRO"

}

],

"more": false

}

Here we can see the balance of account user is 1100 CYBROs





Step-9: Now transfer some tokens from user to tester.

$ cleos push action acc transfer '[ "user", "tester", "250.0000 CYBRO", "testing" ]' -p user

The user acts as the sender and tester, the receiver. 250 CYBRO tokens are transferred into tester account from the user account.

Here we are accessing permission from the user because the user is the only authority who can transfer tokens to another account.