joaomontenegro avatar

Tutorial: EOS accounts and wallets using cleos

joaomontenegro

Published: 19 Jun 2018 › Updated: 19 Jun 2018Tutorial: EOS accounts and wallets using cleos

Tutorial: EOS accounts and wallets using cleos

Creating the Wallet and the Keys

A wallet can store several keys that can be used to sign transactions. Wallets are protected by a password. Creating the wallet and the keys can be done with your machine offline.

1 Create a wallet

cleos wallet create --name myWallet

Result:

Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JZgCiodBwxgcQEsgYNWLnbo8dhUaiCS9mYC5V4tdGjsXEK8xGp"

2 Save the generated wallet password somewhere safe

3 Create a Key pair

cleos create key

Result:

Private key: 5JBbSQpNVQtFt1a3KfJ2EJFGXbr949r2WHFemBsPZckawtEm9yY
Public key: EOS8Pv725YDMJhjJ93iWfEbH1zQUFE66fSqYC8GSqTvPNtGfFbmNG

4 Save the key pair somewhere safe

5 Add private keys to wallet (either created in step 3 or from genesis account)

cleos wallet import 5JBbSQpNVQtFt1a3KfJ2EJFGXbr949r2WHFemBsPZckawtEm9yY --name myWallet

6 Lock the wallet (to test the unlocking on the next step)

cleos wallet lock_all
or
cleos wallet lock --name myWallet

7 Unlock the wallet using the wallet password

cleos wallet unlock --name myWallet
Password: [paste/type wallet password from step 1]

Your wallet is now unlocked, which means that you can now sign transactions with its keys (don’t forget to lock wallet at the end)

Checking an existing account

cleos --url https://mainnet.eoscanada.com get account AccountName

Creating a new account

An account can have several permissions. A permission has a key pair. By default these permissions are:

  • active: used for signing transaction and create other permissions (standard permission)
  • owner: same, but also allows to change the keys for all permissions, including owner itself (like a superuser)

Assumptions:

  • You already have an account (OldAccount) with some staked tokens
  • You have a wallet with the keys from the old account
  • You have chosen a new account name with 12 characters ([a-z] [1-5] and [.])

1 Create two key pairs for the owner and active persmissions and add them to your unlocked wallet

2 Create a new account using the stake from OldAccount

  • With 1 EOS staked for CPU, 1 EOS staked for network and 8 kb of RAM
  • With the same key for the owner and active permissions
cleos --url https://mainnet.eoscanada.com create account --stake-net “1 EOS” --stake-cpu “1 EOS” --buy-ram-kbytes 8 OldAccount NewAccount OwnerPublicKey ActivePublicKey

Alternatively, you can use the same key for both permissions:

cleos --url https://mainnet.eoscanada.com create account --stake-net “1 EOS” --stake-cpu “1 EOS” --buy-ram-kbytes 8 OldAccount NewAccount OwnerAndActivePublicKey 

Transfer tokens

cleos --url https://mainnet.eoscanada.com transfer FromAccount ToAccount “1 EOS”

Unstake tokens

Unstake 1 EOS for network and 2 EOS for CPU from AccountToUnstake using a FromAccount that has some stake. FromAccount will receive the EOS. AccountToUstake and FromAccount can be the same.

cleos --url https://mainnet.eoscanada.com system undelegatebw FromAccount AccountToUnstake "1 EOS" "2 EOS" 

Leave Tutorial: EOS accounts and wallets using cleos to:

Written by

Read more #eos posts


Best Posts From joaomontenegro

We have not curated any of joaomontenegro's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From joaomontenegro