EOS开发(七)使用cleos通过连接第三方节点,在主网/测试网创建账户和发币代币

1.前言

在上一篇文章中,我们已经通过连接第三方节点的方式加入到了主网或者测试网络。这篇文章主要是关于在主网/测试网创建账号,发布代币,以及关于一些转账手续费的讲解。

2.测试网络

2.1 准备工作

生成两组公私钥对,创建账户的时候需要:

yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5Kbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC
yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5Hrxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E

2.2 创建账户

之前,我们是通过http://jungle.cryptolions.ioCreate account选项创建的账户testnetyy111。这里我们使用cleos,通过testnetyy111来创建一个新的账户。

在主网和测试网络中,创建账号不像之前本地私链那样可以随意创建,而是需要为新账户购买和抵押一定的资源,使得新账号可以进行一定的操作,例如转账等。需要购买的资源是RAM,需要抵押的资源是NETCPU。创建账号时,使用以下参数指定要购买和抵押的资源数量:

  • --stake-net:抵押的网络带宽资源,单位为EOS

  • --stake-cpu:抵押的CPU带宽资源,单位为EOS

  • --buy-ram-kbytes:购买的内存资源,单位为KB

  • --buy-ram:购买的内存资源,单位为EOS

创建账户:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "http://jungle.cryptolions.io:18888" create account --stake-net '100 EOS' --stake-cpu '100 EOS' --buy-ram-kbytes 1000 testnetyy111 testneths111 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
ERROR: ExtrasError: [--stake-net --stake-cpu --buy-ram-kbytes testneths111 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E]
Create an account, buy ram, stake for bandwidth for the account
Usage: cleos create account [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
  -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)
  --return-packed             used in conjunction with --dont-broadcast to get the packed transaction
  -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)

发现报错了。通过查看cleos的文档https://developers.eos.io/eosio-cleos/reference#cleos-create-account,发现在生产环境中,创建账号需要使用cleos system newaccount(https://developers.eos.io/eosio-cleos/reference#cleos-system-newaccount)命令替代。

再来:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "http://jungle.cryptolions.io:18888" system newaccount --stake-net '100 EOS' --stake-cpu '100 EOS' --buy-ram-kbytes 1000 testnetyy111 testneths111 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
executed transaction: 28cbc19117ec5c09edd90da7e25b1e742c5a954f7d0a1b2c88be91eceb4b5880  336 bytes  9736 us
#         eosio <= eosio::newaccount            {"creator":"testnetyy111","name":"testneths111","owner":{"threshold":1,"keys":[{"key":"EOS7RkP6aevKj...
#         eosio <= eosio::buyrambytes           {"payer":"testnetyy111","receiver":"testneths111","bytes":1024000}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}
#         eosio <= eosio::delegatebw            {"from":"testnetyy111","receiver":"testneths111","stake_net_quantity":"100.0000 EOS","stake_cpu_quan...
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.stake","quantity":"200.0000 EOS","memo":"stake bandwidth"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.stake","quantity":"200.0000 EOS","memo":"stake bandwidth"}
#   eosio.stake <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.stake","quantity":"200.0000 EOS","memo":"stake bandwidth"}
2018-09-05T06:09:44.828 thread-0   main.cpp:455                  print_result   warning: transaction executed locally, but may not be confirmed by the network yet

成功!我们查询下新账户testneths111的情况:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testneths111
permissions: 
     owner     1:    1 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC
        active     1:    1 EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
memory: 
     quota:     994.9 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        3.661 sec  
     limit:            3.661 sec  

我们刚才创建了新账户testneths111,并为其购买了1000kbRAMNETCPU各抵押了100个eos。

再查查testnetyy111的账户情况:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testnetyy111
permissions: 
     owner     1:    1 EOS6cnhSLTn4eSUEqS4nC8frYTsVsjeH2M3hos1TUeCgme2Yim5Q5
        active     1:    1 EOS6Z7mUQeFC2cQTT3xMyZh2wsLQoHih1bTMgRhr3dbichprTi7Rc
memory: 
     quota:     170.8 KiB    used:     3.646 KiB  

net bandwidth: 
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:               337 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             9.041 ms   
     available:        3.652 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:         9741.6587 EOS
     staked:          200.0000 EOS
     unstaking:         0.0000 EOS
     total:          9941.6587 EOS

producers:     <not voted>

之前这个账号有10000eos的可用余额,现在剩余9741.6587eos的可用余额,刚才创建账号花费了大约258.3413eos,我们来看看花费明细:

  • 各抵押了100eos的NETCPU,总共200eos

  • 购买了1000kb的RAM,花费58.0495eos。可以从创建账号时的返回日记查看:

#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}
  • 购买RAM时,系统收取了0.2918eos的RAM交易手续费。可以从创建账号时的返回日记查看:
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}

合计:

200 + 58.0495 + 0.2918 = 258.3413

正好吻合

staked和delegated

这里注意看下这两个账号的信息。testnetyy111的网络资源和CPU资源都为staked 100 eos,而delegated 0 eostestneths111的网络资源和CPU资源都为delegated 100 eos,而没有staked选项。

这表示的是,testnetyy111的网络资源和CPU资源都是此账号自己抵押的,如果申请赎回,那这200 eos将会退给testnetyy111

testneths111的网络资源和CPU资源都是由testnetyy111抵押的。testneths111无法申请赎回,只能由testnetyy111申请赎回,并且这200 eos将会退给testnetyy111而不是testneths111

2.3 EOS转账

给新账户转点EOS:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 transfer testnetyy111 testneths111 "100 EOS" "hi there"
executed transaction: a2a4d081bf5af18c3f74a3fecb0dd9c65db1490aaeeee00433c9a9a2b83868bc  136 bytes  1540 us
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 EOS","memo":"hi there"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 EOS","memo":"hi there"}
#  testneths111 <= eosio.token::transfer        {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 EOS","memo":"hi there"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

查看testneths111账户信息:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testneths111
permissions: 
     owner     1:    1 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC
        active     1:    1 EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
memory: 
     quota:     994.9 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        3.661 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:          100.0000 EOS
     staked:            0.0000 EOS
     unstaking:         0.0000 EOS
     total:           100.0000 EOS

已经有100eos的余额了

也可以使用下面的方法获取余额:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance eosio.token testnetyy111
9641.6587 EOS
10000.0000 JUNGLE
yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance eosio.token testneths111
100.0000 EOS

JUNGLE是由于testnetyy111账户是通过Jungle Testnet网页创建的,所以默认还给了10000JUNGLE代币

2.4 转账手续费

我们再来查看下testnetyy111账户的情况:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testnetyy111
permissions: 
     owner     1:    1 EOS6cnhSLTn4eSUEqS4nC8frYTsVsjeH2M3hos1TUeCgme2Yim5Q5
        active     1:    1 EOS6Z7mUQeFC2cQTT3xMyZh2wsLQoHih1bTMgRhr3dbichprTi7Rc
memory: 
     quota:     170.8 KiB    used:     3.881 KiB  

net bandwidth: 
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:               455 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             10.13 ms   
     available:        3.651 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:         9641.6587 EOS
     staked:          200.0000 EOS
     unstaking:         0.0000 EOS
     total:          9841.6587 EOS

producers:     <not voted>

对比下转账前RAM、NET、CPU的使用情况:

  • RAM:转账前3.646 KiB used,转账后3.881 KiB used

  • NET:转账前337 bytes used,转账后455 bytes used

  • CPU:转账前9.041 ms used,转账后10.13 ms used

可以看到,转账后testnetyy111各项资源的使用都增加了。转账需要消耗使用EOS抵押的网络和CPU资源,并且需要将testneths111持有了EOS的信息记录到内存上。虽然网络和CPU资源会由系统定期自动释放,也就是恢复,并且可以赎回成EOS,但是内存是使用EOS购买的,虽然可以卖出,但是系统不会定期释放。所以第一次向没有EOS代币的testneths111账户转账多少会有一些(因为使用了内存的)手续费。

为什么说只有第一次转账EOS没有手续费呢?因为经过后续实验,如果testnetyy111再给testneths111转账EOS,testnetyy111的内存消耗并不会增加。原因是,首先,之前内存上已经记录了testneths111持有EOS的信息,转账不会再次记录。其次,虽然转账方testnetyy111的网络和CPU消耗再次增加,但是由于两者的恢复机制,消耗的网络和CPU会再次恢复。所以此时实现了真正意义上的转账无手续费。

我们继续试验。将testneths111的私钥导入testnet.wallet钱包,然后将所有EOS转回给testnetyy111。然后再次查看testnetyy111的账户,这时可以发现,testnetyy111的内存使用降低了。原因是testneths111不再持有EOS,所以系统删除了testneths111持有EOS的这条记录,并将之前的记录此信息的内存退回给了testnetyy111

2.5 创建、发行、转账代币

之前的文章已经详细讲解过代币的创建、发行和转账了,这里不再详细说明了

testnetyy111账户部署代币合约:

uyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 set contract testnetyy111 ../../../build/contracts/eosio.token -p testnetyy111@active
Reading WASM from ../../../build/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
Error 3080001: Account using more than allotted RAM usage
Error Details:
account testnetyy111 has insufficient ram; needs 194060 bytes has 174927 bytes

查看报错信息,发现部署代币合约需要194kb的内存,当前只有174kb。我们为testnetyy111再购买些内存:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 system buyram testnetyy111 testnetyy111 "100 EOS"
executed transaction: 695beb8644042b44b10dcf2028964996c864f9804d7df5182f32ddda92ff8fd4  128 bytes  5017 us
#         eosio <= eosio::buyram                {"payer":"testnetyy111","receiver":"testnetyy111","quant":"100.0000 EOS"}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"99.5000 EOS","memo":"buy ram"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"99.5000 EOS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"99.5000 EOS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.5000 EOS","memo":"ram fee"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.5000 EOS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.5000 EOS","memo":"ram fee"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

买了100eos的内存,实际只买到了99.5eos的内存,因为被系统扣了%0.5的交易手续费。看下现在有多少内存了:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testnetyy111
permissions: 
     owner     1:    1 EOS6cnhSLTn4eSUEqS4nC8frYTsVsjeH2M3hos1TUeCgme2Yim5Q5
        active     1:    1 EOS6Z7mUQeFC2cQTT3xMyZh2wsLQoHih1bTMgRhr3dbichprTi7Rc
memory: 
     quota:     1.831 MiB    used:     3.881 KiB  

net bandwidth: 
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:               549 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             12.96 ms   
     available:        3.648 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:         9541.6587 EOS
     staked:          200.0000 EOS
     unstaking:         0.0000 EOS
     total:          9741.6587 EOS

producers:     <not voted>

足够了。我们重新部署代币合约:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 set contract testnetyy111 ../../../build/contracts/eosio.token -p testnetyy111@active
Reading WASM from ../../../build/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: 7cff6eac58075d3bc12c0479b8bf420f36b7ec2c136a832a007efa48cea57591  8112 bytes  3438 us
#         eosio <= eosio::setcode               {"account":"testnetyy111","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7...
#         eosio <= eosio::setabi                {"account":"testnetyy111","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6...
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

查看一下testnetyy111的账户情况,刚才部署代币合约使用了大约186kb的内存。

完整的创建代币的命令:

cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 create '{"issuer":"testnetyy111", "maximum_supply": "100000000.0000 RAY", "can_freeze": 0, "can_recall": 0, "can_whitelist": 0}' -p testnetyy111@active

can_freezecan_recallcan_whitelist为布尔值,表示这个代币是否可以被发行人冻结,收回,或者白名单。

我们可以也使用更简略的命令创建代币:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 create '[ "testnetyy111", "100000000.0000 RAY", 0, 0, 0]' -p testnetyy111
executed transaction: dfc45b660f42beca5bb0a6dbe081d1d37b4931d004a59bac0801304db6a84ffb  120 bytes  765 us
#  testnetyy111 <= testnetyy111::create         {"issuer":"testnetyy111","maximum_supply":"100000000.0000 RAY"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

我们指定的发行人为testnetyy111。现在将全部代币都发行给testnetyy111

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 issue '[ "testnetyy111", "100000000.0000 RAY", "issue" ]' -p testnetyy111
executed transaction: b0c71715e9dc3284513d6fc29e4c2fc130ff2a54eb621cc472cdc037c63a1124  128 bytes  1303 us
#  testnetyy111 <= testnetyy111::issue          {"to":"testnetyy111","quantity":"100000000.0000 RAY","memo":"issue"}
warning: transaction executed locally, but may not be confirmed by the network yet    ]

查看下余额:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance testnetyy111 testnetyy111
100000000.0000 RAY

现在testnetyy111账户中已经有100000000.0000 RAY,我们转点代币给testneths111

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 transfer '[ "testnetyy111", "testneths111", "100.0000 RAY", "transfer to hs" ]' -p testnetyy111
executed transaction: cc2dd7d3a52f753cf139c4076cfecaa61e4cb853fc91ec9490e26cdaa4052513  144 bytes  1489 us
#  testnetyy111 <= testnetyy111::transfer       {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 RAY","memo":"transfer to hs"}
#  testneths111 <= testnetyy111::transfer       {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 RAY","memo":"transfer to hs"}
warning: transaction executed locally, but may not be confirmed by the network yet    ]

查看下双方的代币余额:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance testnetyy111 testnetyy111
99999900.0000 RAY
yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance testnetyy111 testneths111
100.0000 RAY

没毛病

3. 主网

3.1 准备工作

主网的流程和测试网络基本一样

创建一个钱包,管理主网的私钥

创建一个名为mainnet.wallet的钱包

yuyangdeMacBook-Pro:cleos yuyang$ cleos wallet create -n mainnet --to-console
Creating wallet: mainnet
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

将我之前在主网申请的账户yuyangray222的私钥导入钱包

yuyangdeMacBook-Pro:cleos yuyang$ cleos wallet import --private-key 5JLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -n mainnet
imported private key for: EOS69mwiYuMhfWtwLVXxaXfao7YXF2Kh39nZurdDw6RF1ntQy6DnW

生成两个私钥,创建账户的时候需要:

yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5Jwhxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9
yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5JdJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG

3.2 创建账户

先确认下是否连接的是主网:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" get info
{
  "server_version": "e87d245d",
  "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
  "head_block_num": 14959813,
  "last_irreversible_block_num": 14959477,
  "last_irreversible_block_id": "00e443756eed3ed6a238b63cf87897b069ec84ffb82adceffc3ae0a9469e0b16",
  "head_block_id": "00e444c5fec4a19e4b524c4d84140edb18106b5562cd22d7d7b34fdc90fc1e15",
  "head_block_time": "2018-09-06T03:24:17.500",
  "head_block_producer": "libertyblock",
  "virtual_block_cpu_limit": 200000000,
  "virtual_block_net_limit": 1048576000,
  "block_cpu_limit": 197819,
  "block_net_limit": 1048432,
  "server_version_string": "v1.2.3-dirty"
}

使用yuyangray222创建一个新账户huashangtech

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" system newaccount --stake-net '1 EOS' --stake-cpu '1 EOS' --buy-ram-kbytes 20 yuyangray222 huashangtech EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9 EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG
executed transaction: e10f0e02c963c7b49e939c82ca34917b5607e8925e685d6b48bed27ea372e0a7  336 bytes  5765 us
#         eosio <= eosio::newaccount            {"creator":"yuyangray222","name":"huashangtech","owner":{"threshold":1,"keys":[{"key":"EOS66griGzoa9...
#         eosio <= eosio::buyrambytes           {"payer":"yuyangray222","receiver":"huashangtech","bytes":20480}
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ram","quantity":"2.2453 EOS","memo":"buy ram"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ram","quantity":"2.2453 EOS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ram","quantity":"2.2453 EOS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ramfee","quantity":"0.0113 EOS","memo":"ram fee"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ramfee","quantity":"0.0113 EOS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ramfee","quantity":"0.0113 EOS","memo":"ram fee"}
#         eosio <= eosio::delegatebw            {"from":"yuyangray222","receiver":"huashangtech","stake_net_quantity":"1.0000 EOS","stake_cpu_quanti...
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.stake","quantity":"2.0000 EOS","memo":"stake bandwidth"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.stake","quantity":"2.0000 EOS","memo":"stake bandwidth"}
#   eosio.stake <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.stake","quantity":"2.0000 EOS","memo":"stake bandwidth"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

抵押了1eosNET1eosCPU,购买了20K的内存

查看新账户huashangtech信息:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" get account huashangtech
permissions: 
     owner     1:    1 EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9
        active     1:    1 EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG
memory: 
     quota:     21.27 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        668.9 KiB  
     limit:            668.9 KiB  

cpu bandwidth:
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        126.1 ms   
     limit:            126.1 ms   

3.3 EOS转账

yuyangray222转一个EOS给huashangtech

cleos -u "https://api.eosnewyork.io" transfer yuyangray222 huashangtech "1 EOS" "hi huashangtech"
yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" transfer yuyangray222 huashangtech "1 EOS" "hi huashangtech"
executed transaction: d8fd505b3bbce4416ee390587f758a804218d1057657f189013a62107d6f64a4  144 bytes  1206 us
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"huashangtech","quantity":"1.0000 EOS","memo":"hi huashangtech"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"huashangtech","quantity":"1.0000 EOS","memo":"hi huashangtech"}
#  huashangtech <= eosio.token::transfer        {"from":"yuyangray222","to":"huashangtech","quantity":"1.0000 EOS","memo":"hi huashangtech"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

再次查看huashangtech账户信息:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" get account huashangtech
permissions: 
     owner     1:    1 EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9
        active     1:    1 EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG
memory: 
     quota:     21.27 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        668.9 KiB  
     limit:            668.9 KiB  

cpu bandwidth:
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        126.1 ms   
     limit:            126.1 ms   

EOS balances: 
     liquid:            1.0000 EOS
     staked:            0.0000 EOS
     unstaking:         0.0000 EOS
     total:             1.0000 EOS

余额已有1EOS

3.4 创建、发行、转账代币

由于在主网部署代币合约至少需要账户内有200k的内存,以现在内存的价格,大概需要23个EOS以上,后面有机会再补充,不过流程都和在测试网上基本一致。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342

推荐阅读更多精彩内容