Tutorial: EOS accounts and wallets using cleos

in eos •  7 years ago  (edited)

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" 
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

@joaomontenegro, I gave you an upvote on your first post! Please give me a follow and I will give you a follow in return!

Please also take a moment to read this post regarding bad behavior on Steemit.

Congratulations @joaomontenegro! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @joaomontenegro! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Thanks for this post. Informative!

Congratulations @joaomontenegro! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!