前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >第8课 如何使用开发环境命令行注册EOS靓号?

第8课 如何使用开发环境命令行注册EOS靓号?

作者头像
辉哥
发布2018-08-10 14:23:05
6630
发布2018-08-10 14:23:05
举报
文章被收录于专栏:区块链入门

1,摘要

【本文目标】

通过本文学习,程序员可以在EOS本地环境完成主网心意的12位EOS账号注册。

不愿意折腾的其他人员可参考文档《第2课 不懂技术,如何抢注热门EOS账号?》完成账号注册。

【前置条件】

1)已完成了EOS编译,编译测试成功。未完成的可参考《第4课 如何在UBUNTU虚拟机上编译EOS完成环境搭建?》完成相关配置。

【技术收获】

1) 命令行操作实践完成主网的12位账号注册;

2. 实践操作

为了体验更佳,我们举个场景吧。戈壁创投的徐晨总找到辉哥,希望能帮他注册个他们公司同名的EOS账号(例如:gobipartners),便于后续做区块链投资使用。

2.1 创建新的密钥对,配置钱包

【小提醒】让别人创建EOS账号,密钥对的私钥最好由账号拥有者自行获取,不要让帮忙者自己创建,否则这个账号的安全性存在风险。但是反向考虑,如果能自己创建EOS密钥对,这样的朋友估计也知道怎么创建账号了,那可能就不存在请求帮忙的事情了。

辉哥此处假设跟徐总非常熟悉,也采用命令行方式产生密钥对给徐总用。

1)创建本地钱包

在本地创建一个default钱包,用于给徐总存放账号的,如果钱包已创建,则忽略本步。

cleos wallet create

输出结果:

代码语言:javascript
复制
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

输出结果:(私钥的部分关键字已隐藏)

代码语言:javascript
复制
duncanwang@duncanwang:~$ cleos create key
Private key: 5JkT6Dd9G1**dfajJ8SQpgYzScDBaV***ZFkMG8siw***z9Mf8v
Public key: EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR

3) 新的私钥导入default钱包

cleos wallet import <your_private_key>

输出结果:

代码语言:javascript
复制
duncanwang@duncanwang:~$ cleos wallet import 5JkT6Dd9G1**dfajJ8SQpgYzScDBaV***ZFkMG8siw***z9Mf8v
imported private key for: EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR

2.2 查找主网NODEOS地址

主网的p2p节点地址可以到 EOS Seed List网址查找。找到一个合适的节点后,可以用命令行查看信息。以佳能节点为例,命令如下:

cleos -u https://node1.eoscannon.io get info

输出结果如下:

代码语言:javascript
复制
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 查看,目前的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就可注册?!》

cleos -u https://node1.eoscannon.io get account wangdenghui1

输出结果:

代码语言:javascript
复制
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

输出结果(账号不存在):

代码语言:javascript
复制
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

代码语言:javascript
复制
duncanwang@duncanwang:~$ cleos wallet import 5KH***Mev**JtQW***iXLfVvUFx***D8iL7H***8wAa***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

输出结果(创建成功):

代码语言:javascript
复制
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)查询新创建的账号是否存在

1] 命令行查询方式

cleos -u https://node1.eoscannon.io get account gobipartners

输出结果,显示该账号存在:

代码语言:javascript
复制
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   

2] 网页查询方式

https://eosflare.io输入信息,查询该账号确认已存在。

查询信息

6)创建账号的命令参考

创建系统账号的命令的帮助说明如下,供参考。

代码语言:javascript
复制
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)

4,参考

1) 【系列】EOS智能合约开发41 - 如何连接到EOS主网 & 注册EOS账号?

2) 创建EOS主网账户[古千峰]

本故事纯属虚构,辉哥还没有跟徐晨总建立联系。但是戈壁创投的EOS帐号已注册好了,如有需要可转让给徐总。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018.07.13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 2. 实践操作
    • 2.1 创建新的密钥对,配置钱包
      • 2.2 查找主网NODEOS地址
        • 2.3 注册EOS新账号
        • 4,参考
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档