提交 f4d35a92 编写于 作者: A Andrianto Lie 提交者: Kevin Heifner

update chain api

(cherry picked from commit e2f4c048)
上级 77222f72
......@@ -42,31 +42,31 @@ http-server-endpoint = 127.0.0.1:8888
The `get_info` RPC command can be found at:
```
curl http://127.0.0.1:8888/v1/chain/get_info
$ curl http://127.0.0.1:8888/v1/chain/get_info
```
And it should return something like:
```
{
"head_block_num":449,
"last_irreversible_block_num": 434,
"head_block_id":"000001c1a0f072a5ca76831ac6c6e2988efcf162e953eb40046ec2ceca817a9f",
"head_block_time":"2017-07-18T21:02:24",
"head_block_producer":"initd",
"recent_slots":"0000000000000000000000000000000000000000000000000000000000001111",
"participation_rate":"0.06250000000000000"
"server_version": "7451e092",
"head_block_num": 20561,
"last_irreversible_block_num": 20545,
"head_block_id": "0000505180a0a5fcb6a8e1efbe4cdacc83ec11613fbc8db34d7b2a0b2b483b97",
"head_block_time": "2017-12-08T08:46:18",
"head_block_producer": "initr",
"recent_slots": "1111111111111111111111111111111111111111111111111111111111111111",
"participation_rate": "1.00000000000000000"
}
```
@subsection v1chaingetblock get_block
Get information related to a block.
@subsubsection examplegetblock Example get_block Usage
```
curl http://localhost:8888/v1/chain/get_block -X POST -d '{"block_num_or_id":5}'
curl http://localhost:8888/v1/chain/get_block -X POST -d '{"block_num_or_id":0000000445a9f27898383fd7de32835d5d6a978cc14ce40d9f327b5329de796b}'
$ curl http://127.0.0.1:8888/v1/chain/get_block -X POST -d '{"block_num_or_id":5}'
$ curl http://127.0.0.1:8888/v1/chain/get_block -X POST -d '{"block_num_or_id":0000000445a9f27898383fd7de32835d5d6a978cc14ce40d9f327b5329de796b}'
```
@subsubsection examplegetblockresult Example get_block Result
......@@ -92,7 +92,7 @@ Get information related to an account.
@subsubsection examplegetaccount Example get_account Usage
```
curl http://localhost:8888/v1/chain/get_account -X POST -d '{"name":"inita"}'
$ curl http://127.0.0.1:8888/v1/chain/get_account -X POST -d '{"name":"inita"}'
```
@subsubsection examplegetaccountresult Example get_account Result
......@@ -143,7 +143,7 @@ Fetch smart contract code.
@subsubsection examplegetcode Example get_code Usage
```
curl http://localhost:8888/v1/chain/get_code -X POST -d '{"name":"currency"}'
$ curl http://127.0.0.1:8888/v1/chain/get_code -X POST -d '{"account_name":"currency"}'
```
@subsubsection examplegetcoderesult Example get_code Result
......@@ -151,51 +151,44 @@ curl http://localhost:8888/v1/chain/get_code -X POST -d '{"name":"currency"}'
{
"name":"currency",
"code_hash":"a1c8c84b4700c09c8edb83522237439e33cf011a4d7ace51075998bd002e04c9",
"wast":"(module\n (type $0 (func (param i64 i64 i32) (result i32)))\n ...",
"wast":"(module\n (type $0 (func (param i64 i64 i32) (result i32)))\n ...truncated",
"abi": {
"types": [
{
"new_type_name": "account_name",
"type": "name
}
],
"structs": [
{
"name": "transfer",
"base": "",
"fields": {
"from": "account_name",
"to": "account_name",
"amount": "uint64"
}
},
{
"name": "account",
"base": "",
"fields": {
"account": "name,
"balance": "uint64"
}
}
],
"actions": [
{
"name": "transfer",
"type": "transfer"
}
],
"tables": [
{
"name": "account",
"index_type": "i64",
"key_names": [
"account"
],
"key_types": [],
"type": "account"
}
]
}
<<<<<<< HEAD
"types": [{
"new_type_name": "account_name",
"type": "name"
}
],
"structs": [{
"name": "transfer",
"base": "",
"fields": [
{"name":"from", "type":"account_name"},
{"name":"to", "type":"account_name"},
{"name":"quantity", "type":"uint64"}
]
},{
"name": "account",
"base": "",
"fields": [
{"name":"key", "type":"name"},
{"name":"balance", "type":"uint64"}
]
}
],
"actions": [{
"name": "transfer",
"type": "transfer"
}
],
"tables": [{
"name": "account",
"type": "account",
"index_type": "i64",
"key_names" : ["key"],
"key_types" : ["name"]
}
]
}
```
......@@ -206,8 +199,8 @@ Fetch smart contract data from an account.
@subsubsection examplegettablerows get_table_rows Usage
```
curl http://localhost:8888/v1/chain/get_table_rows -X POST -d '{"scope":"inita", "code":"currency", "table":"account", "json": true}'
curl http://localhost:8888/v1/chain/get_table_rows -X POST -d '{"scope":"inita", "code":"currency", "table":"account", "json": true, "lower_bound":0, "upper_bound":-1, "limit":10}'
$ curl http://127.0.0.1:8888/v1/chain/get_table_rows -X POST -d '{"scope":"inita", "code":"currency", "table":"account", "json": true}'
$ curl http://127.0.0.1:8888/v1/chain/get_table_rows -X POST -d '{"scope":"inita", "code":"currency", "table":"account", "json": true, "lower_bound":0, "upper_bound":-1, "limit":10}'
```
@subsubsection examplegettablerowsresult Example get_table_rows Result
......@@ -230,13 +223,13 @@ Serialize json to binary hex. The resulting binary hex is usually used for the d
@subsubsection exampleabijsontobin Example abi_json_to_bin Usage
```
curl http://localhost:8888/v1/chain/abi_json_to_bin -X POST -d '{"code":"currency", "action":"transfer", "args":{"from":"initb", "to":"initc", "amount":1000}}'
$ curl http://127.0.0.1:8888/v1/chain/abi_json_to_bin -X POST -d '{"code":"currency", "action":"transfer", "args":{"from":"initb", "to":"initc", "quantity":1000}}'
```
@subsubsection exampleabijsontobinresult Example abi_json_to_bin Result
```
{
"binargs": "000000000041934b000000008041934be803000000000000",
"binargs": "000000008093dd74000000000094dd74e803000000000000",
"required_scope": [],
"required_auth": []
}
......@@ -249,7 +242,7 @@ Serialize back binary hex to json.
@subsubsection exampleabibintojson Example abi_bin_to_json Usage
```
curl http://localhost:8888/v1/chain/abi_bin_to_json -X POST -d '{"code":"currency", "action":"transfer", "binargs":"000000000041934b000000008041934be803000000000000"}'
$ curl http://127.0.0.1:8888/v1/chain/abi_bin_to_json -X POST -d '{"code":"currency", "action":"transfer", "binargs":"000000008093dd74000000000094dd74e803000000000000"}'
```
@subsubsection exampleabibintojsonresult Example abi_bin_to_json Result
......@@ -258,7 +251,7 @@ curl http://localhost:8888/v1/chain/abi_bin_to_json -X POST -d '{"code":"curren
"args": {
"from": "initb",
"to": "initc",
"amount": 1000
"quantity": 1000
},
"required_scope": [],
"required_auth": []
......@@ -302,9 +295,14 @@ Content-Length: 1466
```
@subsubsection examplepushtrx Example push_transaction Usage
This example assumes a transfer operation. The `ref_block_num` and `ref_block_prefix` are provided as a result of `/v1/chain/get_block`.
This example assumes a transfer operation. The `ref_block_num` and `ref_block_prefix` here are provided as a result of `/v1/chain/get_block` of the last_irreversible_block.
You also need to use /v1/wallet/sign_transaction to get the right signature.
```
<<<<<<< HEAD
curl http://localhost:8888/v1/chain/push_transaction -X POST -d '{"ref_block_num":"100","ref_block_prefix":"137469861","expiration":"2017-09-25T06:28:49","scope":["initb","initc"],"actions":[{"code":"currency","type":"transfer","recipients":["initb","initc"],"authorization":[{"account":"initb","permission":"active"}],"data":"000000000041934b000000008041934be803000000000000"}],"signatures":[],"authorizations":[]}'
=======
$ curl http://127.0.0.1:8888/v1/chain/push_transaction -X POST -d '{"ref_block_num":21453,"ref_block_prefix":3165644999,"expiration":"2017-12-08T10:28:49","scope":["initb","initc"],"read_scope":[],"messages":[{"code":"currency","type":"transfer","authorization":[{"account":"initb","permission":"active"}],"data":"000000008093dd74000000000094dd74e803000000000000"}],"signatures":["1f393cc5ce6a6951fb53b11812345bcf14ffd978b07be386fd639eaf440bca7dca16b14833ec661ca0703d15e55a2a599a36d55ce78c4539433f6ce8bcee0158c3"]}'
>>>>>>> e2f4c048... update chain api
```
......@@ -314,7 +312,11 @@ This method push multiple transactions at once.
@subsubsection examplepushtrxs Example push_transactions Usage
```
<<<<<<< HEAD
curl http://localhost:8888/v1/chain/push_transaction -X POST -d '[{"ref_block_num":"101","ref_block_prefix":"4159312339","expiration":"2017-09-25T06:28:49","scope":["initb","initc"],"actions":[{"code":"currency","type":"transfer","recipients":["initb","initc"],"authorization":[{"account":"initb","permission":"active"}],"data":"000000000041934b000000008041934be803000000000000"}],"signatures":[],"authorizations":[]}, {"ref_block_num":"101","ref_block_prefix":"4159312339","expiration":"2017-09-25T06:28:49","scope":["inita","initc"],"actions":[{"code":"currency","type":"transfer","recipients":["inita","initc"],"authorization":[{"account":"inita","permission":"active"}],"data":"000000008040934b000000008041934be803000000000000"}],"signatures":[],"authorizations":[]}]'
=======
$ curl http://127.0.0.1:8888/v1/chain/push_transaction -X POST -d '[{"ref_block_num":21453,"ref_block_prefix":3165644999,"expiration":"2017-12-08T10:28:49","scope":["initb","initc"],"read_scope":[],"messages":[{"code":"currency","type":"transfer","authorization":[{"account":"initb","permission":"active"}],"data":"000000008093dd74000000000094dd74e803000000000000"}],"signatures":["1f393cc5ce6a6951fb53b11812345bcf14ffd978b07be386fd639eaf440bca7dca16b14833ec661ca0703d15e55a2a599a36d55ce78c4539433f6ce8bcee0158c3"]},...]'
>>>>>>> e2f4c048... update chain api
```
......@@ -324,7 +326,11 @@ Get required keys to sign a transaction from list of your keys.
@subsubsection examplegetrequiredkeys Example get_required_keys Usage
```
<<<<<<< HEAD
curl http://localhost:8888/v1/chain/get_required_keys -X POST -d '{"transaction": {"ref_block_num":"100","ref_block_prefix":"137469861","expiration":"2017-09-25T06:28:49","scope":["initb","initc"],"actions":[{"code":"currency","type":"transfer","recipients":["initb","initc"],"authorization":[{"account":"initb","permission":"active"}],"data":"000000000041934b000000008041934be803000000000000"}],"signatures":[],"authorizations":[]}, "available_keys":["EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq","EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA","EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"]}'
=======
$ curl http://127.0.0.1:8888/v1/chain/get_required_keys -X POST -d '{"transaction": {"ref_block_num":"100","ref_block_prefix":"137469861","expiration":"2017-09-25T06:28:49","scope":["initb","initc"],"messages":[{"code":"currency","type":"transfer","recipients":["initb","initc"],"authorization":[{"account":"initb","permission":"active"}],"data":"000000000041934b000000008041934be803000000000000"}],"signatures":[],"authorizations":[]}, "available_keys":["EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq","EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA","EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"]}'
>>>>>>> e2f4c048... update chain api
```
@subsubsection examplegetrequiredkeysresult Example get_required_keys Result
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册