**版本：V6.2.0**  
**环境：bityuan主链**  
全新环境创建钱包环境流程：  
生成种子（seed generate）→保存种子(seed save)→解锁钱包(wallet unlock)→生成地址（account create）  
即**14.1→14.3→23.11→1.2**

# CLI命令总览
```
Available Commands:
  account     Account management
  asset       Asset query
  block       Get block header or body info
  cert        generate cert
  close       Close 
  coins       Construct system coins transactions
  config      Configuration
  exec        Executor operation
  hashlock    Hashlock operation
  help        Help about any command
  mempool     Mempool management
  multisig    multisig management
  net         Net operation
  para        Construct para transactions
  retrieve    Wallet retrieve operation
  seed        Seed management
  send        Send transaction in one step
  stat        Coin statistic
  ticket      Ticket management
  token       Token management
  trade       Token trade management
  tx          Transaction management
  unfreeze    Unfreeze construct management
  version     Get node version
  wallet      Wallet management

```


# 1.account模块
`cli account -h`
```
Available Commands:
  balance     Get balance of a account address
  create      Create a new account with label
  dump_key    Dump private key for account address
  import_key  Import private key with label
  list        Get account list
  set_label   Set label for account address
```
针对account模块的操作，需在本地钱包已拥有种子（seed），且钱包状态为已解锁的前提下。

## 1.1 account balance 地址余额查询
`cli account balance -a 查询地址 -e 执行器名称（合约）--height 指定高度（可选项）`
```
{
    "balance": "4662.8270",
    "frozen": "107492660.0000",
    "addr": "14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
}
```
可以指定具体的执行器查询，不指定时显示所有有余额的执行器；  
可以指定具体高度查询，未指定时默认为-1（最新）。  
目前支持的执行器为："none", "coins", "manage", "ticket", "hashlock", "multisig", "paracross", "retrieve", "token", "trade", "unfreeze" 和 user-defined type  


## 1.2 account create 新建钱包地址
`cli account create -l 自定义地址标签`
```
{
    "acc": {
        "balance": "0.0000",
        "frozen": "0.0000",
        "addr": "152xusBV1onddSYcyTmGcGr1Yva7GAc37w"
    },
    "label": "test1"
}
```
标签不可重复；由钱包种子生成的地址可以被种子（助记词）恢复。  


## 1.3 account dump_key 钱包地址私钥导出
`cli account dump_key -a 本钱包中的地址`
```
{
    "data": "0x3e611fde7175fbda1212a6c24cc605b209058af47565903cf7a0f3bc6087b4d1"
}
```

## 1.4 account import_key 外部私钥导入钱包
`cli account import_key -k 外部私钥`
```
{
    "acc": {
        "balance": "6390.1750",
        "frozen": "0.0000",
        "addr": "18jUpfSuYCk2iQu8ZqB3d6hNWNWA4ty3Xs"
    },
    "label": "test2"
}
```
标签不可与已有标签重复；私钥不可与已有私钥重复。  

## 1.5 account list 本地钱包地址coins余额列表显示
`cli account list` 
```
{
    "wallets": [
        {
            "acc": {
                "balance": "0.0000",
                "frozen": "0.0000",
                "addr": "1EsHHaV4eLvNLwR2cHUn2gqAsdKe9F3AAh"
            },
            "label": "node award"
        },
        {
            "acc": {
                "balance": "0.0000",
                "frozen": "0.0000",
                "addr": "13C8Kddauj259McKWBD1SPNagdJXRgcmEm"
            },
            "label": "test1"
        }
    ]
}
```
列表仅列出coins合约下钱包各地址的余额；  
标签为**node award**的是6.1及前版本数据库生成的空投地址，不会被钱包种子保存，操作中尽量不要使用该地址。  
6.2版本后空投地址标签改为**airdropaddr**，由种子生成，可以恢复但不建议使用。  

## 1.6 account set_label 修改地址的标签名
`cli account set_label -a 本钱包中的地址 -l 新标签名`
```
{
    "acc": {
        "balance": "0.0000",
        "frozen": "0.0000",
        "addr": "152xusBV1onddSYcyTmGcGr1Yva7GAc37w"
    },
    "label": "ttt2"
}
```
新标签不可与已存在标签重复。  


# 2.block模块
`cli block -h`
```
Available Commands:
  add_callback           add block sequence call back
  get                    Get blocks between [start, end]
  hash                   Get hash of block at height
  headers                Get block headers between [start, end]
  last_callback_sequence last call back sequence by name
  last_header            View last block header
  last_sequence          View last block sequence
  list_callback          list block sequence call back
  query_hashs            Query block by hashs
  sequences              Get block sequences between [start, end]
  view                   View block info by block hash

```
## 2.1 block add_callback 向指定地址推送消息  
`cli block add_callback -e (数据，支持json和proto buff) -n 名称（string格式） -u（指定地址url，string格式）`  
```
{
    "isOK": true,
    "msg": ""
}
```
对端返回ok后可记录对应sequence。  


## 2.2 block get 获取指定区块高度区间内的区块体信息
`cli block get -s 起始查询高度 -e 结束查询高度 -d 是否选择显示详情（可选）`
```
{
    "items": [
        {
            "block": {
                "version": 0,
                "parenthash": "0xfd57208afa1e8f6dc34f2800453cf427d071a03eb67c367b2ae7277f987ad7ee",
                "txhash": "0x0a3d08e2d7cf824dd12116540e67b5315b2b678fd659d1f0539eb5d510cc24d8",
                "statehash": "0x2c0b23d66dde05b7c268a293c5ba04858b79fbab0261f3fef9888929ff30b49b",
                "height": 1,
                "blocktime": 1526541151,
                "txs": [
                    {
                        "execer": "ticket",
                        "payload": {
                            "miner": {
                                "bits": 520159231,
                                "reward": "1800000000",
                                "ticketId": "1M4ns1eGHdHak3SNc2UTQB75vnXyJQd91s:0xf5d9a5dd179739da8cfc5b296be665edd65e7bd1a15571dd1423ff4a14a41f07:0000002503",
                                "modify": "modify",
                                "privHash": null
                            },
                            "ty": 16
                        },
                        "rawpayload": "0x501022860108ffff83f8011080a4a7da061a70314d346e73316547486448616b33534e6332555451423735766e58794a51643931733a3078663564396135646431373937333964613863666335623239366265363635656464363565376264316131353537316464313432336666346131346134316630373a3030303030303235303322066d6f64696679",
                        "signature": {
                            "ty": 1,
                            "pubkey": "0x024eb415515013b42990c0454db7c5e8ff342dda947e7e4adbf310ee999557bf40",
                            "signature": "0x3044022045b2de43a363b495d2ce992a622f4f649b5ba3d62cee91cc4ebf51d69f8e626602204da1881e23cf41670f8ad051eedd5552660264a3ceab0d455f794dfcc7593561"
                        },
                        "fee": "0.0010",
                        "expire": 0,
                        "nonce": 1914288556955278013,
                        "to": "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp",
                        "from": "1M4ns1eGHdHak3SNc2UTQB75vnXyJQd91s",
                        "hash": "0x0a3d08e2d7cf824dd12116540e67b5315b2b678fd659d1f0539eb5d510cc24d8"
                    }
                ]
            },
            "receipts": null
        }
    ]
}
```

※-d后为可选项，0/f/false为不显示，1/t/true为显示。不输入-d默认为不显示。

## 2.3 block hash 获取指定区块高度的区块哈希
`cli block hash -t 区块高度`
```
{
    "hash": "0x09055102ecb36033adde0fc9c0d523500c1d81693e7ad12181cfc2497b407da9"
}
```

## 2.4 block headers 获取指定区块高度区间内的区块头信息
`cli block headers -s 起始查询高度 -e 结束查询高度`
```
{
    "items": [
        {
            "version": 0,
            "parentHash": "0x67c58d6ba9175313f0468ae4e0ddec946549af7748037c2fdd5d54298afd20b6",
            "txHash": "0xa8ac95a4e8b1504337ac05d52a7526740485ec73b22971a4384efe4586c0d53e",
            "stateHash": "0x0493c5b870cda0461bcc0be3f6d2fd4b561156ddcb9770149e8953b2266980cd",
            "height": 1,
            "blockTime": 1520348437,
            "txCount": 1,
            "hash": "0x09055102ecb36033adde0fc9c0d523500c1d81693e7ad12181cfc2497b407da9",
            "difficulty": 520159231
        },
        {
            "version": 0,
            "parentHash": "0x09055102ecb36033adde0fc9c0d523500c1d81693e7ad12181cfc2497b407da9",
            "txHash": "0xfe1fe37787fc6127f146a3413d19ade46876b2d35c827c91bbddc39df8c0b45d",
            "stateHash": "0x408d99ffe95229ee3c9fbb012e48a2754264e15156f7c8e6dd8fe6dada9079b2",
            "height": 2,
            "blockTime": 1520348438,
            "txCount": 1,
            "hash": "0xcbf3ed1647c053d1c0e1f8a7dc2a1fa4b16ce6e76464003e21f3978b3fcc2dcc",
            "difficulty": 520159231
        }
    ]
}
```
※cli命令中有-d的可选参数项，但无实际作用，为了保持与block get结构一致，可省略。  

## 2.5 block last_callback_sequence 获取最新callback的sequence
`cli block last_callback_sequence -n 名称（string格式）`  
```
{
    "data": -1
}
```
需推送后得到对端的正常返回才可获取sequence；若不存在则返回-1。  

## 2.6 block last_header 获取本钱包当前已同步的最新区块的区块头信息
`cli block last_header`
```
{
    "version": 0,
    "parentHash": "0x97a11064615404999d9ee59e2e224b3441307bee77aa554e44cbcf38130eeab7",
    "txHash": "0xc3ac690ec79510d7a6edf6f9ecd3bd0dd54354e09e665d1de89bd22e9b170190",
    "stateHash": "0xbffce7dd0ca63338534b0cd4822b8bd4c2ec2cb6c3d15bc2634b978413762014",
    "height": 142754,
    "blockTime": 1522717715,
    "txCount": 2,
    "hash": "0xf867641e0fb6c9596722bf6691b27ef085a9b26690e5c0121d510d3fc6f75569",
    "difficulty": 520126523
}
```

## 2.7 block last_sequence 获取本钱包当前已同步的最新顺序编号）
`cli block last_sequence `
```
158216
```
※sequence是否开启的配置项在配置文件中，默认应为关闭，返回为01，表示不存在。

## 2.8 block list_callback 获取本钱包发送的callback列表  
`cli block list_callback`
```
{
    "items": [
        {
            "name": "11",
            "URL": "http://localhost:8901",
            "encode": "111"
        }
    ]
}
```
## 2.9 block query_hashs 根据区块哈希获取区块详情
`cli block query_hashs "哈希1 哈希2"`

返回内容解析了具体详情。  

## 2.10 block sequences 根据顺序编号查询对应的区块哈希
`cli block sequences -s 起始查询高度 -e 结束查询高度`
```
{
    "blkseqInfos": [
        {
            "hash": "0x1e160b70e7698a40fa5f73db0a4a0d42a3d26ae6dc2038aa84ae283173ddf0e4",
            "type": 1
        },
        {
            "hash": "0xae42f51d3e21ef6169ab2c40892b88359d069008178040cde07e87fc8f37fdd0",
            "type": 1
        }
    ]
}
```
## 2.11 block view 根据区块哈希查询指定区块的区块头信息
`cli block view -s 区块哈希`
```
{
    "head": {
        "version": 0,
        "parentHash": "0x799fef7cc6869833f3e01e91a794cecde9b1c687ad43876e70f665686c938b9c",
        "txHash": "0x37186edb0d5448beaece89ec76b49c9b228ae7debd724e47188ec690c04e0a7c",
        "stateHash": "0x788d6debabdbf8bfdaa62b918b6cacc3ed17de649decf4a7466d721aa1a1e01c",
        "height": 10,
        "blockTime": 1520348526,
        "txCount": 1,
        "hash": "0x1e160b70e7698a40fa5f73db0a4a0d42a3d26ae6dc2038aa84ae283173ddf0e4",
        "difficulty": 520159231
    },
    "txCount": 1,
    "txHashes": [
        "0x37186edb0d5448beaece89ec76b49c9b228ae7debd724e47188ec690c04e0a7c"
    ]
}
```

# 3.cert模块 
`cli cert -h`
```
Flags:
      --ca                   whether this cert should be its own Certificate Authority
      --duration duration    Duration that certificate is valid for (default 8760h0m0s)
      --ecdsa-curve string   ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521
  -h, --help                 help for cert
      --host string          Comma-separated hostnames and IPs to generate a certificate for
      --rsa-bits int         Size of RSA key to generate. Ignored if --ecdsa-curve is set (default 2048)
      --start-date string    Creation date formatted as Jan 1 15:04:05 2011

```
主要用于联盟链，在此不加详述。  

# 4.close模块

## 4.1 cli close 关闭chain33
`cli close`  
执行关闭chian33的操作。
```
{
    "isOK": true,
    "msg": ""
}
```
# 5.coins模块
`cli coins -h`
```
Available Commands:
  send_exec   Create a send to executor transaction
  transfer    Create a transfer transaction
  txgroup     Create a transaction group
  withdraw    Create a withdraw transaction

```
在6.1及前版本中，使用的是bty模块命令，后因平行链的拓展使用，统一改为coins模块。  


## 5.1 coins send_exec 构造指定地址向指定执行器转账的交易
`cli coins send_exec -e 执行器名字 -a 数量 -n 备注（可选）`
```
未签名的十六进制字符串
```
※ 完成一笔交易需要经过**构建-签名-发送**三步操作。

## 5.2 coins transfer 构造coins合约转账交易
`cli coins transfer -t 目标地址 -a 数量 -n 备注（可选）`
```
未签名的十六进制字符串
```

## 5.3 coins txgroup 构造交易组交易
构建交易组交易，后文提供例子详述。

## 5.4 coins withdraw 构造从指定执行器取回的交易
`cli bty withdraw -e 执行器名字 -a 数量 -n 备注（可选）`
```
未签名的十六进制字符串
```

# 6.config模块 
`cli config -h`
```
Available Commands:
  config_tx    set system config
  query_config Query config item
```

## 6.1 config_tx 构造管理员权限配置交易
`cli config config_tx -c 操作目标 -o 操作行为 -v 目标对象`
```
返回未签名的十六进制字符串
```

※ 这是构造权限配置的交易，需用管理员私钥进行签名并发送。-  
-c后可跟token-finisher或token-blacklist，相应的-v后跟的为地址或symbol。-o后可选择项为add或delete。

## 6.2 query_config 查询配置
`cli config query_config -k 操作目标`
```
{
    "key": "token-finisher",
    "value": "[1BkeZk7uJghsqjF1nck7NgXm64i9UYGR5b 112EMwXFTAMrePGgb6fm2zY7ZHU9rQX9Uv 1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK 1Pnx9e6xoGea11ivN11EE9C19cZTKTerdm 1JzEPPB4j9Z2cBHeHR62JkkGDdy3HmMgse 1AbkwxzV6toQXiSNr2ZtKkK48TuLXzoxuG 15cWZ3hQhpksmKZoznRc7h1fBuUpaUFzPc 15qn2zv9ba5gTydX1uUfcUdVXYgydzD5vs 16RW9gq3QJPAkvwu3zgBNZBJgSArADdb6T 18ATbJ2CJ6kqHRnpE7G7sy8A7Xzt2hjdzK]"
}
```
-k后可查询token-finisher或token-blacklist。 


# 7.exec模块
`cli exec -h`
```
Available Commands:
  addr        Get address of executor
  userdata    Write data to user defined executor
```

## 7.1 exec addr 获取指定执行器的合约地址
`cli exec addr -e 执行器名称`
```
返回合约地址
```

※ 目前支持的执行器包括：("none", "coins", "manage", "ticket", "hashlock", "multisig", "paracross", "retrieve", "token", "trade", "unfreeze" and user-defined type)

## 7.2 exec userdata 构造用区块链发送文件信息
```cli exec userdata -d "`cat ~/xxx.md`" -e "user.write" -t "md" ```  
-d后跟数据，可指定具体路径下的文件，支持md格式；  
-e后接自定义执行器，必须以user.开头；  
-t后跟标题。  

# 8.hashlock模块  
`cli hashlock -h`
```
Available Commands:
  lock        Create hashlock lock transaction
  send        Create hashlock send transaction
  unlock      Create hashlock unlock transaction

```
因为这是一个独立的合约系统，在后文单独以案例形式说明。  


# 9.mempool模块
`cli mempool -h`
```
Available Commands:
  last_txs    Get latest mempool txs
  list        List mempool txs
  proper_fee  Get latest proper fee

```

## 9.1 mempool last_txs获取内存池中最近十笔交易
`cli mempool last_txs`
```
返回最近10笔交易的交易详情
```

※ 未完成同步时，不会从其他节点接收，返回为空。

## 9.2 mempool list 获取内存池中的交易列表
`cli mempool list`
```
返回内存池中现存的交易详情列表
```

## 9.3 mempool proper_fee 获取内存池中最新交易适当的手续费
`cli mempool proper_fee`
```
{
    "properFee": 300000
}
```
返回值需除以十的八次方后，即为0.003。  

# 10.multisig模块  
`cli multisig -h`
```
Available Commands:
  account     multisig account
  owner       multisig owner
  tx          multisig tx
```
因为这是一个独立的合约系统，在后文单独以案例形式说明。  


# 11.net模块  
`cli net -h`
```
Available Commands:
  fault         Get system fault
  info          Get net information
  is_clock_sync Get ntp clock synchronization status
  is_sync       Get blockchain synchronization status
  peer_info     Get remote peer nodes
  time          Get time status
```

## 11.1 net fault 查询本节点出现重大故障的次数
`cli net fault `
```
返回故障次数
```
正常情况下为0，出现数据库损坏等故障会增加。主要用于客户端判断出现故障时的原因。

## 11.2 net info 查询本节点的网络信息
`cli net info`
```
{
    "externalAddr": "122.224.166.26:39345",
    "localAddr": "192.168.1.113:13802",
    "service": true,
    "outbounds": 3,
    "inbounds": 3
}
```
※ service分为能否对外提供服务；outbounds为接收外部节点的数量，inbounds为本节点对外提供服务的节点数量。

## 11.3 net is_clock_sync 查询本节点时间是否同步
`cli net is_clock_sync`
```
返回true或false
```

## 11.4 net is_sync 查询本节点是否已同步
`cli net is_sync`
```
返回true或false
```

## 11.5 net peer_info 查询本节点向外连接节点的节点信息
`cli net peer_info`
```
{
    "peers": [
        {
            "addr": "114.55.101.159",
            "port": 13802,
            "name": "02f440816eef113a12e2348a33a13495fcbe81b8c8b85168046d92069b0e7a1a48",
            "mempoolSize": 1,
            "self": false,
            "header": {
                "version": 0,
                "parentHash": "0x645a21b25ca09df22784e3f7c149fc5651ed26646ff097df8e5951e128ddc7c8",
                "txHash": "0x16ac8f1321081e273da7c9e27741d7ba80ad5a1321f79a2dcc01e13d1cba31f3",
                "stateHash": "0x031edd1de63fe60c894775c5ffa41ffa8df3ad1d6e96dde5f3453dd96f5f4727",
                "height": 692406,
                "blockTime": 1532508302,
                "txCount": 2,
                "hash": "0x7f2f0f230c57e967616f8661a3a7eac199660a3b96b5e3e54c703520048a297d",
                "difficulty": 0
            }
        },
        {
            "addr": "122.224.166.26",
            "port": 39345,
            "name": "02a1a707b987b430fa22ca2ff45ec0c2eee70a61de7ed32bcd4d4583b7317090fe",
            "mempoolSize": 0,
            "self": true,
            "header": {
                "version": 0,
                "parentHash": "0xc8c40356665c2482c36ef9ba9077ceba6c336c46b6fe964fe7b3c2e6ec042aeb",
                "txHash": "0x990af1fe87aa441ba4d0897bd57378dd3717f151f9ec89f0e55ae09c6a5d909f",
                "stateHash": "0x9ba01e88490551265f1fcf8220c24de693253dd319cfd393cfff562745e5c747",
                "height": 513089,
                "blockTime": 1529372099,
                "txCount": 2,
                "hash": "0xd77b0ecaf0527f2cb94e2d164b993b65536d1a9614da87adf91b758abea746e8",
                "difficulty": 0
            }
        }
    ]
}
```
 ※ self：true即为本节点

## 11.6 net time 获取本地时间与ntp时间

 cli net time
 ```
{
    "ntpTime": "2018-07-25 16:49:48",
    "localTime": "2018-07-25 16:49:47",
    "diff": -1
}
```

## 12.para模块  
`cli para -h`
```
Available Commands:
  asset_transfer   Create a asset transfer to para-chain transaction
  asset_withdraw   Create a asset withdraw to para-chain transaction
  blocks           Get blocks with main chain hash map between [start, end], the same in main
  height           query consensus height
  is_sync          query parachain is sync
  node             Create a super node manage cmd
  node_list        Get node info list by status
  node_status      Get node current vote status
  nodegroup        apply for para chain's super node group
  nodegroup_addrs  Get super node group's addrs by title
  nodegroup_list   query super node group apply list by status
  nodegroup_status query super node group apply status by title
  para_list        Get para chain info list by titles
  para_status      Get para chain current status
  transfer         Create a transfer transaction
  transfer_exec    Create a transfer to exec transaction
  withdraw         Create a withdraw transaction
```
该模块主要用于跨链、平行链超级节点相关，由单独篇幅介绍。  


# 13.retrieve模块
`cli retrieve -h`
```
Available Commands:
  backup      Backup the wallet
  cancel      Cancel the retrieve
  perform     Perform the retrieve
  prepare     Prepare the wallet
  query       Backup the wallet
```
因为这是一个独立的合约系统，在后文单独以案例形式说明。  



# 14.seed模块  
`cli seed -h`
```
Available Commands:
  generate    Generate seed
  get         Get seed by password
  save        Save seed and encrypt with passwd
```

## 14.1 seed generate 生成种子
`cli seed generate -l 0`
```
crime aerobic elevator vibrant fork cotton tent ginger gift weird shoe photo fold winner artwork
```
※ -l 后接种子语言位，0为英文，1为中文

## 14.2 seed get 获取本钱包的种子
`cli seed get -p 本钱包密码`
```
{
    "seed": "great forum expect long pencil tortoise question thumb sell crane record rough embody enjoy globe"
}
```
使用该命令需将本地钱包解锁。  

## 14.3 seed save 将种子保存为本钱包种子
cli seed save -s 种子 -p 密码
```
{
    "isOK": true,
    "msg": ""
}
```

※ 一个钱包只能有一个种子。  
密码设置需符合规则，[8,30]，字母数字需都拥有。

# 15.send模块 
```
Use similarly as bty/token/trade/bind_miner raw transaction creation, in addition to the parameter of private key or from address input following "-k".
e.g.: cli send bty transfer -a 1 -n note -t toAddr -k privKey/fromAddr
```
※ 代替构造-签名-发送三步模式的简易方式，支持任何交易，针对任何构造的交易，在该构造结构最前加上send，再加上-k签名或本钱包拥有的地址即可。  


# 16.stat模块
`cli stat -h`
```
Available Commands:
  exec_balance Get the exec amount of a token of one address (default: all exec-addr bty of current height of one addr)
  total_coins  Get total amount of a token (default: bty of current height)

```
※ stat模块需要在配置文件中，将exec中的enableStat置为true，并且节点从0开始同步。
## 16.1 stat exec_balance 查询指定资产在指定合约下的余额和冻结  
`cli stat exec_balance -a 地址 -e 资产执行器名称（可选） -x 指定合约地址（可选） -t 指定高度（可选）  -s 资产名（可选）`  
```
{
    "totalAmount": "60645655.9370",
    "frozenAmount": "60644850.0000",
    "activeAmount": "805.9370",
    "execBalances": [
        {
            "execAddr": "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp",
            "frozen": "60644850.0000",
            "active": "805.8870"
        },
        {
            "execAddr": "1BwqcsyB9BpZawRwrbn8GNHJJN4LKg6pRo",
            "frozen": "0.0000",
            "active": "0.0500"
        }
    ]
}
```
-e后的资产执行器名称目前可设为coins/token/paracross，默认空为coins；  
-x指定的是合约地址，可通过查询合约名称获取；  
-t指定高度，默认空为-1，最新高度；  
-s指定资产名称，默认空为bty，若为token可具体指定。  



## 16.2 stat total_coins 获取全网所有coins的交易数和总量 
`cli stat total_coins`
```
{
    "txCount": 3282974,
    "accountCount": 0,
    "totalAmount": "374511302.9999"
}
```


# 17.ticket模块
`cli ticket -h`
```
Available Commands:
  bind_miner  Bind private key to miner address
  close       Close tickets
  cold        Get cold wallet address of miner
  count       Get ticket count
```

## 17.1 ticket bind_miner 构造离线挖矿授权
`cli ticket bind_miner -b 在线挖矿地址 -o 离线授权地址`
```
返回十六进制字符串
```

※ 详见离线挖矿

## 17.2 ticket close 关闭挖矿
`cli ticket close -m 挖矿地址（可选）`
```
返回交易哈希
```

※ 需要先关闭钱包的自动挖矿状态，否则返回ErrMinerNotClosed；无票可关闭时返回no ticket to be close。若存在多个可关闭ticket的地址，会返回多个哈希。   
针对离线挖矿，挖矿地址改变的情况下，可以-m后跟在线挖矿的地址，会扫描该地址是否有关联的离线地址的私钥在本钱包中。若存在，则会关闭ticket。避免在线地址的私钥丢失的情况下无法关闭的问题。  



## 17.3 ticket cold 根据指定在线挖矿地址获取离线授权地址
`cli ticket cold -m 在线挖矿地址`
```
{
    "datas": [
        "1Lw6QLShKVbKM6QvMaCQwTh5Uhmy4644CG"
    ]
}
```

## 17.4 ticket count 获取本钱包正在挖矿的票数
`cli ticket count`
```
返回票数
```

# 18.token模块
`cli token -h`
```
Available Commands:
  burn               Create a burn token transaction
  finish             Create a finish created token transaction
  get_finish_created Get finish created tokens
  get_precreated     Get precreated tokens
  get_token_logs     Get logs of token
  mint               Create a mint token transaction
  precreate          Create a precreated token transaction
  revoke             Create a token revoke transaction
  send_exec          Create a token send to executor transaction
  token_assets       Get token assets
  token_balance      Get token balance of one or more addresses
  transfer           Create a token transfer transaction
  withdraw           Create a token withdraw transaction
```
详见发行token  


# 19.trade模块
`cli trade -h`
```
Available Commands:
  buy                     Create a buying token transaction
  buy_limit               Create a buy limit transaction
  buy_order               Show one's buying orders
  revoke                  Create a revoke token transaction
  revoke_buy              Create a revoke buy limit transaction
  sell                    Create a selling token transaction
  sell_market             Create a sell market transaction
  sell_order              Show one's token selling orders
  status_buy_order        Show one's buying orders of tokens
  status_order            Show one's orders with status
  status_sell_order       Show selling orders of the status
  status_token_buy_order  Show token buying orders of a status
  status_token_sell_order Show token selling orders of a status
```

详见trade

# 20.tx模块
`cli tx -h`
```
Available Commands:
  addr_overview View transactions of address
  decode        Decode a hex format transaction
  get_hex       Get transaction hex by hash
  query         Query transaction by hash
  query_addr    Query transaction by account address
  query_hash    Get transactions by hashes
  rewrite       rewrite transaction parameters
```

## 20.1 tx addr_overview 查询指定地址在coins合约下的相关交易
`cli tx addr_overview -a 地址`
```
{
    "receiver": "129148559.4869",
    "balance": "1.1880",
    "txCount": 641586
}
```

## 20.2 tx decode 对交易字符串进行解析
`cli tx decode -d 字符串`
```
{
    "txs": [
        {
            "execer": "coins",
            "payload": {
                "transfer": {
                    "cointoken": "",
                    "amount": "100000000",
                    "note": null,
                    "to": "1EYAvmDtGVptFnD8MrXQwDyQq3vvkCRzq2"
                },
                "ty": 1
            },
            "rawpayload": "0x18010a291080c2d72f222231455941766d447447567074466e44384d72585177447951713376766b43527a7132",
            "signature": {
                "ty": 1,
                "pubkey": "0x034105712cb5f4c6c9e4575c8042c5cf870b0412db233f7800bbced8d0d2885bd0",
                "signature": "0x3045022100be9df5408062dada5e58d1c3fb992f01fac213068edc2a06ac2c9feca9a969da02200c69f6bd3255c02e45b1ae2f1ce1c6627158e93f6cf66fcad686150be658f5e1"
            },
            "fee": "0.0010",
            "expire": 1559118964,
            "nonce": 4693767684884574685,
            "to": "1EYAvmDtGVptFnD8MrXQwDyQq3vvkCRzq2",
            "from": "1K7Fko7e21F2qXdYriVLheJue5ZW5KerZL",
            "hash": "0xbfd05e37c26da71106031c37643dcabbd7bc1bee10a063af50d3f97495712330"
        }
    ]
}

```


## 20.3 tx get_hex 根据交易哈希获取十六进制字符串
`cli tx get_hex -s 交易哈希`
```
返回十六进制字符串
```

## 20.4 tx query 根据交易哈希获取交易详情
`cli tx query -s 交易哈希`
```
返回交易详情
```

## 20.5 tx query_addr 根据地址获取交易列表
`cli tx query_addr -a 地址 -c 数量（可选）-d 方向（可选） -f 类型（可选） -t 指定高度（可选） 区块中索引号（可选）`
```
{
    "txInfos": [
        {
            "hash": "0xf01bb61179882f01c732f812389e8fb202871a580bd82203cf22b7b1b74d13fe",
            "height": 689216,
            "index": 2
        },
        {
            "hash": "0xb29faa0def9897600b240b037ded7a42d99ac7f04ebb2f7774f98021cfa6bf06",
            "height": 630732,
            "index": 2
        }
    ]
}
```
※ -c的数量默认为10个；  
-d输入0为正向，-1为反向，默认为0；  
-f后为该地址在交易中的类型，0为全部，1为发送者，-1为接受者，默认为0； 
-t为指定高度之后开始查询，-1为从最新高度开始查询，默认为-1；
-i为从区块指定索引开始查询，范围区间[0,100000]，默认为0。  



## 20.6 tx query_hash 根据交易哈希（组）获取交易详情
`cli tx query_hash -s "交易哈希1 交易哈希2"`
```
返回交易详情1
返回交易详情2
```

## 20.7 tx rewrite 重写交易
`cli tx rewrite -e 超时时间（可选） -f 手续费（可选） -i 交易组的索引值（可选） -t 目标地址（可选） -s 十六进制字符串`  
```
十六进制字符串
```
针对已签名或未签名的交易都可重写覆盖；已签名的交易重写后需重新签名。  

## 21.unfreeze模块  
`cli unfreeze -h`
```
Available Commands:
  create        create unfreeze construct
  list          list unfreeze
  show          show construct
  show_withdraw show available withdraw amount of one unfreeze construct
  terminate     terminate construct
  withdraw      withdraw asset from construct
```
详见trade

# 22.version模块 获取本节点chain33版本号
`cli version`
```
{
    "title": "bityuan",
    "app": "6.1.1.0507",
    "chain33": "6.1.1",
    "localDb": "1.0.0"
}
```

# 23.wallet模块 
`cli wallet -h`
```
Available Commands:
  auto_mine   Set auto mine on/off
  list_txs    List transactions in wallet
  lock        Lock wallet
  merge       Merge accounts' balance into address
  nobalance   Create nobalance transaction
  send        Send a transaction
  set_fee     Set transaction fee
  set_pwd     Set password
  sign        Sign transaction
  status      Get wallet status
  unlock      Unlock wallet
```

## 23.1 wallet auto_mine 自动挖矿开启开关
`cli wallet auto_mine -f 1`
```
{
    "isOK": true,
    "msg": ""
}
```

※ -f后跟的0为关闭，1为开启

## 23.2 wallet list_txs 获取本钱包的交易列表
`cli wallet list_txs -c 显示交易数量 -d 查询方向（0逆向，1正向） -f 开始查询的交易字符串`
```
返回交易详情
```

※ -f中查询的交易字符串，满足("%018d", height*100000 + index）的规则

## 23.3 wallet lock 锁定钱包
`cli wallet lock`
```
{
    "isOK": true,
    "msg": ""
}
```

## 23.4 wallet merge 钱包中地址余额合并
`cli wallet merge -t 合并目标地址`
```
返回交易哈希
```

## 23.5 wallet nobalance 对不涉及转账金额的交易构造不需要手续费的交易组
`cli -d 未签名的字符串 -k 签名私钥`
```
返回交易组字符串
```

※ 也可以选择-a 签名地址 来完成签名

## 23.6 wallet send 对已完成签名的交易进行发送
`cli wallet send -d 已签名的字符串 -t 发送token名称的字符串（默认为BTY）`
```
返回交易哈希
```

## 23.7 wallet set_fee 设置交易手续费
`cli wallet set_fee -a 设置的交易费`
```
{
    "isOK": true,
    "msg": ""
}
```

## 23.8 wallet set_pwd 设置钱包密码
`cli wallet set_pwd -n 新密码 -o 旧密码`
```
{
    "isOK": true,
    "msg": ""
}
```

## 23.9 wallet sign 对已构造的交易进行签名
`cli wallet sign -d 未签名交易的字符串 -a 签名地址/-k 签名私钥 -e 超时时间（默认为120秒） `
```
返回签名的字符串
```

## 23.10 wallet status 获取钱包状态
`cli wallet status`
```
{
    "isWalletLock": true,
    "isAutoMining": true,
    "isHasSeed": true,
    "isTicketLock": true
}
```

## 23.11 wallet unlock 解锁钱包
`cli wallet unlock -p 密码 -t 解锁时间（默认为无限长）`
```
{
    "isOK": true,
    "msg": ""
}
```


