百度区块链 XuperChain开发教程(第二部分)

百度区块链 XuperChain开发教程(第二部分)

 

第一部分编译完成后,现在开始进入测试部分:

 


$ cd output/
$ ./xchain-cli createChain

 

 

msg="create block chain by contract" module=xchain from=xuper toCreate=xuper
msg="ledger meta" module=xchain genesis_block= tip_block= trunk_height=0
msg="utxo total is estimated" module=xchain total=0
msg="debug tx" module=xchain txid=b8b4dd25f2ad6e54e29dc8ed60407110850085693e0c8815a5591cb5da1021dc
msg=txoutput module=xchain offset=0 addr=dpzuVdosQrF2kmzumhVeFQZa1aYcdgFpN amount=100000000000000000000
msg="begin format genesis block" module=xchain
msg="Start to ConfirmBlock" module=xchain
msg="start to confirm block" module=xchain blockid=0f190368b903c6d6e94a52b949e45d46c1224d5dbfca69edf1246950d8f823ee txCount=1
msg="print block size when confirm block" module=xchain blockSize=1371 blockid=0f190368b903c6d6e94a52b949e45d46c1224d5dbfca69edf1246950d8f823ee
msg="confirm block cost" module=xchain blkTimer="saveHeader: 0.08 ms,saveAllTxs: 0.08 ms,saveToDisk: 0.06 ms,total: 0.34ms"
msg="ConfirmBlock Success" module=xchain Height=1
msg="hit queryblock cache" module=xchain blkid=0f190368b903c6d6e94a52b949e45d46c1224d5dbfca69edf1246950d8f823ee
msg="unconfirm table size" module=xchain unconfirmTxMap=0
msg="autogen tx list size, before play block" module=xchain len=0
msg="  start to dotx" module=xchain txid=b8b4dd25f2ad6e54e29dc8ed60407110850085693e0c8815a5591cb5da1021dc
msg="    insert utxo key" module=xchain utxoKey=UdpzuVdosQrF2kmzumhVeFQZa1aYcdgFpN_b8b4dd25f2ad6e54e29dc8ed60407110850085693e0c8815a5591cb5da1021dc_0 amount=100000000000000000000
msg="autogen tx list size, after play block" module=xchain len=0



 

 

$ ls -lth ./data/blockchain/xuper/
total 12K
drwxr-xr-x 2 john john 4.0K 8月   1 13:31 utxoVM
drwxr-xr-x 2 john john 4.0K 8月   1 13:31 ledger
-rw-r--r-- 1 john john 1011 8月   1 13:31 xuper.json

 

 

$ nohup ./xchain &

 

 

 

$ ./xchain-cli status
{
  "blockchains": [
    {
      "name": "xuper",
      "ledger": {
        "rootBlockid": "0f190368b903c6d6e94a52b949e45d46c1224d5dbfca69edf1246950d8f823ee",
        "tipBlockid": "d6d1a3bc5c3938a22ffdc7261fb41a5f6de608a8029030a6a611c0b4931146b0",
        "trunkHeight": 19,
        "maxBlockSize": 134217728
      },
      "utxo": {
        "latestBlockid": "d6d1a3bc5c3938a22ffdc7261fb41a5f6de608a8029030a6a611c0b4931146b0",
        "lockKeyList": null,
        "utxoTotal": "100000000000019000000",
        "avgDelay": 0,
        "unconfirmed": 0
      }
    }
  ],
  "peers": null,
  "speeds": {
    "BcSpeeds": {
      "xuper": {}
    }
  }
}

 

下一步开始创建账户

 

$ ./xchain-cli account --help
Operate an account or address: balance|new|newkeys|split.

Usage:
  xchain-cli account [command]

Available Commands:
  balance     Query the balance of an account or address.
  contracts   query account's contracts
  new         Create an account.
  newkeys     Create an address with public key and private key.
  query       query the account list containing a specific address.
  split       Split the utxo of an account or address.

Flags:
  -h, --help   help for account

Global Flags:
      --config string       config file (default is ./xchain.yaml)
      --cryptotype string   crypto type, eg. default (default "default")
  -H, --host string         server node ip:port (default "127.0.0.1:37101")
      --keys string         directory of keys (default "data/keys")
      --name string         block chain name (default "xuper")

Use "xchain-cli account [command] --help" for more information about a command.

 

$ ./xchain-cli account newkeys --output data/test_demo
create account using crypto type default
create account in data/test_demo

 

$ ls -lth data/test_demo/
total 12K
-rw-r--r-- 1 john john  33 8月   1 13:42 address
-rw-r--r-- 1 john john 266 8月   1 13:42 private.key
-rw-r--r-- 1 john john 184 8月   1 13:42 public.key

 

cat data/keys/address 
******************

 

在百度测试链上查看账户信息:

$ ./xchain-cli account balance ********** -H 14.215.179.74:37101

 

 

你可能感兴趣的:(区块链)