【本文目標】node
經過本文學習,程序員能夠在EOS本地環境完成主網心意的12位EOS帳號註冊,而且能夠經過EOS本地環境完成EOS註冊帳號的active key和owner key的變動。程序員
在EOS帳號是其餘人代爲註冊時,私鑰每每也被其餘人知曉,存在泄漏風險,建議儘快完成變動。json
【前置條件】vim
1)已完成了EOS編譯,編譯測試成功。未完成的可參考如何在UBUNTU虛擬機上編譯EOS完成環境搭建?(附代碼)安全
【技術收穫】微信
1) 命令行操做實踐完成主網的12位帳號註冊;app
2) cleos set account permission的使用;ide
2.1 建立新的密鑰對,配置錢包學習
【小提醒】讓別人建立EOS帳號,密鑰對的私鑰最好由帳號擁有者自行獲取,不要讓幫忙者本身建立,不然這個帳號的安全性存在風險。可是反向考慮,若是能本身建立EOS密鑰對,這樣的朋友估計也知道怎麼建立帳號了,那可能就不存在請求幫忙的事情了。區塊鏈
1)建立本地錢包
在本地建立一個default錢包,用於給徐總存放帳號的,若是錢包已建立,則忽略本步。
cleos wallet create
輸出結果:
duncanwang@duncanwang:~$ cleos wallet create Creating wallet: default Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable. "PW5K6PTcK1nfr6RT9KfcMtzZDcrM7ZqvtBnAnPyYcigH5HR15roDL"
2)建立新帳號所需的密鑰對
cleos create key
輸出結果:(私鑰的部分關鍵字已隱藏)
duncanwang@duncanwang:~$ cleos create key Private key: 5JkT6Dd9G1**dfajJ8SQpgYzScDBaV***ZFkMG8siw***z9Mf8v Public key: EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR
3) 新的私鑰導入default錢包
cleos wallet import <your_private_key>
輸出結果:
duncanwang@duncanwang:~$ cleos wallet import 5JkT6Dd9G1**dfajJ8SQpgYzScDBaV***ZFkMG8siw***z9Mf8vimported private key for: EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR
2.2 查找主網NODEOS地址
主網的p2p節點地址能夠到 EOS Seed List網址(https://eosnodes.privex.io/)查找。找到一個合適的節點後,能夠用命令行查看信息。以佳能節點爲例,命令以下:
cleos -u https://node1.eoscannon.io get info
輸出結果以下:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get info { "server_version": "6ee30205", "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906", "head_block_num": 5448946, "last_irreversible_block_num": 5448615, "last_irreversible_block_id": "005323a7c602e9a643226f6e00b3709858c9f42f05c7381b457e0f38c2ef2d74", "head_block_id": "005324f2e20f241d036b46560812fcc1dc6e5dfe6644351a6c3ab699f27b0e3f", "head_block_time": "2018-07-12T06:10:33.000", "head_block_producer": "argentinaeos", "virtual_block_cpu_limit": 200000000, "virtual_block_net_limit": 1048576000, "block_cpu_limit": 192923, "block_net_limit": 1046944 }
說明下,「chain_id」這個字段,它是主鏈ID,能夠到 eos.host(https://eos.host/mainnet) 查看,目前的chain_id是 aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906,一致的。
【說明】用命令行的方式也能夠找到全部節點的列表。命令以下:
cleos -u https://node1.eoscannon.io system listproducers -l 1000
2.3 註冊EOS新帳號
1) 確認建立父帳號的資源是否充足
輝哥爲別人建立賬號,意味着輝哥把本身的一部分計算資源分配給了他,因此須要消耗EOS。
注意:全部帳號名必須爲12個字符,包括a-z以及1-5,不含0。 小於12位的EOS帳號是須要拍賣的,參考文檔《第3課 驚天祕訣,2位帳號如JD只要0.5個EOS就可註冊?!》(https://www.jianshu.com/p/51f29a1c3cba)。
cleos -u https://node1.eoscannon.io get account wangdenghui1
輸出結果:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account wangdenghui1 permissions: owner 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V active 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V memory: quota: 24.96 KiB used: 4.021 KiB net bandwidth: delegated: 0.0501 EOS (total staked delegated to account from others) used: 519 bytes available: 26.13 KiB limit: 26.64 KiB cpu bandwidth: delegated: 0.3001 EOS (total staked delegated to account from others) used: 10.15 ms available: 20.96 ms limit: 31.11 ms producers: <not voted>
按照經驗,建立一個EOS新帳號須要消耗的資源以下,目前輝哥帳號的資源還知足建立要求。
NET Stake (in EOS): 0.05 CPU Stake (in EOS): 0.1 RAM (in kbytes):8
2) 查詢帳號是否存在
cleos -u https://node1.eoscannon.io get account gobipartners
輸出結果(帳號不存在):
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners 892747ms thread-0 main.cpp:2712 main ] Failed with error: unspecified (0)
3)導入wangdenghui1的私鑰到duncanwang錢包
部分私鑰內容已隱藏。
cleos wallet import <私鑰> -n duncanwang
duncanwang@duncanwang:~$ cleos wallet import 5KHMevJtQWiXLfVvUFxD8iL7H8wAa*YZR54 -n duncanwang
imported private key for: EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V
4)註冊EOS新帳戶名
調用eosio.system合約的newaccount Action,命令以下:
cleos -u https://node1.eoscannon.io system newaccount -x 1000 --stake-net '0.0010 EOS' --stake-cpu '0.0010 EOS' --buy-ram-kbytes 8 <映射分配的account_name> <要申請的新帳號名> <EOS公鑰>
【參數的含義】
-x 1000:1000s內最長反饋時間;
--stake-net:使用帶寬抵押的EOS;
--stake-cpu:使用CPU抵押的EOS;
--buy-ram-kbytes:購買的內存(最低8KB);
<映射分配的account_name>:即第3步記下來的12個字符的帳戶名;
<要申請的新帳號名>:一樣是12個字符,只能使用小寫字母a-z,和數字1-5;
<EOS公鑰>
【經驗】
NET Stake (in EOS): 0.05
CPU Stake (in EOS): 0.1
RAM (in kbytes):8
cleos -u https://node1.eoscannon.io system newaccount -x 1000 --stake-net "0.1 EOS" --stake-cpu "0.1 EOS" --buy-ram-kbytes 8 wangdenghui1 gobipartners EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR
輸出結果(建立成功):
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io system newaccount -x 1000 --stake-net "0.1 EOS" --stake-cpu "0.1 EOS" --buy-ram-kbytes 8 wangdenghui1 gobipartners EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR 1229333ms thread-0 main.cpp:429 create_action ] result: {"binargs":"109c6e6caac4a6e180af9af99aea0e6500200000"} arg: {"code":"eosio","action":"buyrambytes","args":{"payer":"wangdenghui1","receiver":"gobipartners","bytes":8192}} 1229958ms thread-0 main.cpp:429 create_action ] result: {"binargs":"109c6e6caac4a6e180af9af99aea0e65e80300000000000004454f5300000000e80300000000000004454f530000000000"} arg: {"code":"eosio","action":"delegatebw","args":{"from":"wangdenghui1","receiver":"gobipartners","stake_net_quantity":"0.1000 EOS","stake_cpu_quantity":"0.1000 EOS","transfer":false}} executed transaction: d0c3543b6db8787a151a748ab73d0dec9210442cf7022a442c42fa9fe2a27f3c 336 bytes 5477 us # eosio <= eosio::newaccount {"creator":"wangdenghui1","name":"gobipartners","owner":{"threshold":1,"keys":[{"key":"EOS8gaYL4uHyA... # eosio <= eosio::buyrambytes {"payer":"wangdenghui1","receiver":"gobipartners","bytes":8192} # eosio.token <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.ram","quantity":"2.9714 EOS","memo":"buy ram"} # wangdenghui1 <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.ram","quantity":"2.9714 EOS","memo":"buy ram"} # eosio.ram <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.ram","quantity":"2.9714 EOS","memo":"buy ram"} # eosio.token <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.ramfee","quantity":"0.0150 EOS","memo":"ram fee"} # wangdenghui1 <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.ramfee","quantity":"0.0150 EOS","memo":"ram fee"} # eosio.ramfee <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.ramfee","quantity":"0.0150 EOS","memo":"ram fee"} # eosio <= eosio::delegatebw {"from":"wangdenghui1","receiver":"gobipartners","stake_net_quantity":"0.1000 EOS","stake_cpu_quanti.. .# eosio.token <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.stake","quantity":"0.2000 EOS","memo":"stake bandwidth"} # wangdenghui1 <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.stake","quantity":"0.2000 EOS","memo":"stake bandwidth"} # eosio.stake <= eosio.token::transfer {"from":"wangdenghui1","to":"eosio.stake","quantity":"0.2000 EOS","memo":"stake bandwidth"} warning: transaction executed locally, but may not be confirmed by the network yet
5)查詢新建立的帳號是否存在
cleos -u https://node1.eoscannon.io get account gobipartners
輸出結果,顯示該帳號存在:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners permissions: owner 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR active 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR memory: quota: 7.959 KiB used: 2.926 KiB net bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 0 bytes available: 53.17 KiB limit: 53.17 KiB cpu bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 0 us available: 10.37 ms limit: 10.37 ms
在https://eosflare.io輸入信息,查詢該帳號確認已存在。
6)建立帳號的命令參考
建立系統帳號的命令的幫助說明以下,供參考。
duncanwang@duncanwang:~$ cleos system newaccount -h Create an account, buy ram, stake for bandwidth for the account Usage: cleos system newaccount [OPTIONS] creator name OwnerKey [ActiveKey] Positionals: creator TEXT The name of the account creating the new account (required) name TEXT The name of the new account (required) OwnerKey TEXT The owner public key for the new account (required) ActiveKey TEXT The active public key for the new account Options: -h,--help Print this help message and exit --stake-net TEXT The amount of EOS delegated for net bandwidth (required) --stake-cpu TEXT The amount of EOS delegated for CPU bandwidth (required) --buy-ram-kbytes UINT The amount of RAM bytes to purchase for the new account in kibibytes (KiB), default is 8 KiB --buy-ram TEXT The amount of RAM bytes to purchase for the new account in EOS --transfer Transfer voting power and right to unstake EOS to receiver -x,--expiration set the time in seconds before a transaction expires, defaults to 30s -f,--force-unique force the transaction to be unique. this will consume extra bandwidth and remove any protections against accidently issuing the same transaction multiple times -s,--skip-sign Specify if unlocked wallet keys should be used to sign transaction -j,--json print result as json -d,--dont-broadcast don't broadcast transaction to the network (just print to stdout) -r,--ref-block TEXT set the reference block num or block id used for TAPOS (Transaction as Proof-of-Stake) -p,--permission TEXT ... An account and permission level to authorize, as in 'account@permission' --max-cpu-usage-ms UINT set an upper limit on the milliseconds of cpu usage budget, for the execution of the transaction (defaults to 0 which means no limit) --max-net-usage UINT set an upper limit on the net usage budget, in bytes, for the transaction (defaults to 0 which means no limit)
3.1 經過TokenPocket錢包建立密鑰對
經過TokenPocket官網(https://www.mytokenpocket.vip/)下載錢包版本。
安裝後,經過 發現 > EOS助手 > 帳號註冊 > 密碼生成器 完成密鑰對的生成。
3.2 密鑰導入
來到本地EOS環境,親自把私鑰導入duncanwang本地錢包。
【說明】此步操做能夠在別的任意EOS開發環境完成導入工做。
cleos wallet import <新的私鑰> -n duncanwang
3.3 權限變動
1) 查看gobipartners帳號信息
cleos -u https://node1.eoscannon.io get account gobipartners
輸出結果代表 owner key 和 active key仍是輝哥的密鑰對。
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners permissions: owner 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR active 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR memory: quota: 7.959 KiB used: 2.926 KiB net bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 0 bytes available: 55.92 KiB limit: 55.92 KiB cpu bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 0 us available: 10.9 ms limit: 10.9 ms
3.4 變動帳戶active權限爲徐總公鑰
假設產生的公鑰Public key以下:EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V
命令格式:
cleos set account permission <轉讓帳戶名> active '{"threshold":1,"keys":[{"key":"<對方公鑰>","weight":1}]}' owner
輸出結果:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io set account permission gobipartners active '{"threshold":1,"keys":[{"key":"EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V","weight":1}]}' ownerexecuted transaction: 0b7ab9fe92413e6b4b5d25578afdef81438c73adac015972ce56f59c570034e9 160 bytes 1317 us # eosio <= eosio::updateauth {"account":"gobipartners","permission":"active","parent":"owner","auth":{"threshold":1,"keys":[{"key... warning: transaction executed locally, but may not be confirmed by the network yet 查詢確認active的KEY已發生變動: duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners permissions: owner 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR active 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V memory: quota: 7.959 KiB used: 2.926 KiB net bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 161 bytes available: 55.76 KiB limit: 55.92 KiB cpu bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 1.122 ms available: 9.779 ms limit: 10.9 ms
3.5 變動帳戶owner爲徐總公鑰
命令格式:
cleos set account permission <轉讓帳戶名> owner '{"threshold":1,"keys":[{"key":"<對方公鑰>","weight":1}]}' -p <轉讓帳戶名>@owner
輸出結果:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io set account permission -x 120 gobipartners owner '{"threshold":1,"keys":[{"key":"EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V","weight":1}]}' -p gobipartners@owner executed transaction: ed1593fee153baa7b02e1e3e1155e732c3e7db4fbb3fd50ff73b0de1a04d5831 160 bytes 1186 us # eosio <= eosio::updateauth {"account":"gobipartners","permission":"owner","parent":"","auth":{"threshold":1,"keys":[{"key":"EOS... warning: transaction executed locally, but may not be confirmed by the network yet
【問題】輸入命令提示錯誤,信息以下:
duncanwang@duncanwang:~$ cleos set account permission gobipartners owner '{"threshold":1,"keys":[{"key":"EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V","weight":1}]}' -p gobipartners@owner Error 3090003: provided keys, permissions, and delays do not satisfy declared authorizations Ensure that you have the related private keys inside your wallet and your wallet is unlocked.
初步估計是跟主網節點鏈接處理的時間不夠,增長-x 120,把等待時間改成2分鐘,就成功了。
查詢確認owner的KEY已發生變動:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners permissions: owner 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V active 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V memory: quota: 7.959 KiB used: 2.926 KiB net bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 318 bytes available: 55.61 KiB limit: 55.92 KiB cpu bandwidth: delegated: 0.1000 EOS (total staked delegated to account from others) used: 1.628 ms available: 9.273 ms limit: 10.9 ms
本文做者:HiBlock區塊鏈技術佈道羣-輝哥
原文發佈於簡書
原文連接:
https://www.jianshu.com/p/ef09a0ce4231
https://www.jianshu.com/p/c6bd914dc2d0
加微信baobaotalk_com,加入技術佈道羣
線上課程推薦
【線上課程】4節課8小時培訓,《白話區塊鏈》做者蔣勇教你快速掌握區塊鏈智能合約開發
線下活動推薦