获取所有命令
命令格式:$ cleos
cleos包含所有命令的文档。有关cleos已知的所有命令的列表,只需简单地运行它,不带任何参数:
$ cleos
ERROR: RequiredError: Subcommand required
Command Line Interface to EOSIO Client
Usage: cleos [OPTIONS] SUBCOMMAND
Options:
-h,--help 打印帮助信息并且退出
-u,--url TEXT=http://localhost:8888/
nodeos 运行的http/https URL
--wallet-url TEXT=http://localhost:8888/
keosd运行的 http/https URL
-v,--verbose 输出对错误的详细操作
子命令:
version 返回版本信息
create 在区块链上和区域外创建数据
get 从区块链中检索各种数据和信息
set 设置或更新区块链状态
transfer 从账户到账户转移EOS
net 与本地p2p网络连接进行交互
wallet 与本地钱包互动
sign 签署交易
push 将任意事务推送到区块链
multisig Multisig合约命令
system 将eosio.system合约行为发送到区块链。
获取所有子命令
命令格式: $ cleos ${command}
要获得有关任何特定子命令的帮助,请使用无参数运行它:
$ cleos create
ERROR: RequiredError: Subcommand required
Create various items, on and off the blockchain
Usage: ./cleos create SUBCOMMAND
Subcommands:
key Create a new keypair and print the public and private keys
account Create a new account on the blockchain
producer Create a new producer on the blockchain
$ cleos create account
ERROR: RequiredError: creator
Create a new account on the blockchain
Usage: ./cleos create account creator name OwnerKey ActiveKey
Positionals:
creator TEXT The name of the account creating the new account
name TEXT The name of the new account
OwnerKey TEXT The owner public key for the account
ActiveKey TEXT The active public key for the account
链接节点
命令格式:$ cleos --url ${node}:${port}
这会将你连接到本地节点
$ cleos -u localhost:8889
$ cleos --url localhost:8889
你还可以调整节点参数以连接到其他节点,例如公共测试网
$ cleos -H test1.eos.io -p 80
注意 你需要在每个请求中包含-H和-p参数来解决问题
查询区块链状态
命令格式:$ cleos get info
$ cleos get info
{
"server_version": "7451e092",
"head_block_num": 6980,
"last_irreversible_block_num": 6963,
"head_block_id": "00001b4490e32b84861230871bb1c25fb8ee777153f4f82c5f3e4ca2b9877712",
"head_block_time": "2017-12-07T09:18:48",
"head_block_producer": "initp",
"recent_slots": "1111111111111111111111111111111111111111111111111111111111111111",
"participation_rate": "1.00000000000000000"
}
通过transaction_id获取交易
命令格式:$ cleos get transaction ${transaction_id}
通过在nodeos中加载account_history_api_plugin,我们可以使用transaciton_id查询特定事务
$ cleos get transaction eb4b94b72718a369af09eb2e7885b3f494dd1d8a20278a6634611d5edd76b703
{
"transaction_id": "eb4b94b72718a369af09eb2e7885b3f494dd1d8a20278a6634611d5edd76b703",
"processed": {
"refBlockNum": 2206,
"refBlockPrefix": 221394282,
"expiration": "2017-09-05T08:03:58",
"scope": [
"inita",
"tester"
],
"signatures": [
"1f22e64240e1e479eee6ccbbd79a29f1a6eb6020384b4cca1a958e7c708d3e562009ae6e60afac96f9a3b89d729a50cd5a7b5a7a647540ba1678831bf970e83312"
],
"messages": [{
"code": "eos",
"type": "transfer",
"authorization": [{
"account": "inita",
"permission": "active"
}
],
"data": {
"from": "inita",
"to": "tester",
"amount": 1000,
"memo": ""
},
"hex_data": "000000008040934b00000000c84267a1e80300000000000000"
}
],
"output": [{
"notify": [{
"name": "tester",
"output": {
"notify": [],
"sync_transactions": [],
"async_transactions": []
}
},{
"name": "inita",
"output": {
"notify": [],
"sync_transactions": [],
"async_transactions": []
}
}
],
"sync_transactions": [],
"async_transactions": []
}
]
}
}
通过帐户获取交易
命令格式:$ cleos get transaction ${account}
我们也可以查询某个账户从最近一个账户开始执行的交易清单
$ cleos get transactions inita
[
{
"transaction_id": "eb4b94b72718a369af09eb2e7885b3f494dd1d8a20278a6634611d5edd76b703",
...
},
{