RPC API
-
- CHAIN
- get_info
- get_block
- get_block_header_state
- get_account
- get_abi
- get_raw_code_and_abi
- get_table_rows
- abi_json_to_bin
- abi_bin_to_json
- get_required_keys
- get_currency_stats
- get_producers
- push_block
- push_transaction
- push_transactions
- HISTORY
- NET
- PRODUCER
- pause
- resume
- paused
- get_runtime_options
- update_runtime_options
- get_greylist
- add_greylist_accounts
- remove_greylist_accounts
- get_whitelist_blacklist
- set_whitelist_blacklist
- DBSIZE
RPC API
CHAIN
get_info
返回包含区块链的各种详细信息的对象。
1 | POST http://127.0.0.1:8888/v1/chain/get_info |
示例:
1 | curl --request POST \ |
执行结果:
1 | { |
get_block
返回一个对象,其中包含有关区块链上特定块的各种详细信息。
1 | POST http://127.0.0.1:8888/v1/chain/get_block |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| block_num_or_id | string | Provide a block number or a block id |
REQUIRED |
执行结果:
1 | { |
get_block_header_state
获取可逆区块头状态。
1 | POST http://127.0.0.1:8888/v1/chain/get_block_header_state |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| block_num_or_id | string | Provide a block number or a block id |
/ |
get_account
返回一个对象,其中包含有关区块链上特定帐户的各种详细信息。
1 | POST http://127.0.0.1:8888/v1/chain/get_account |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| account_name | string | Provide an account name | REQUIRED |
执行结果:
1 | { |
get_abi
获取账户的 abi 数据。
1 | POST http://127.0.0.1:8888/v1/chain/get_abi |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| account_name | string | name of account to retrieve ABI for | / |
执行结果:
1 | { |
get_raw_code_and_abi
获取账户的原始 code 和 abi 数据。
1 | POST http://127.0.0.1:8888/v1/chain/get_raw_code_and_abi |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| account_name | string | Account name to get code and abi for | / |
执行结果:
1 | { |
get_table_rows
返回包含指定表中行的对象。
1 | POST http://127.0.0.1:8888/v1/chain/get_table_rows |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| scope | string | Provide the account name | REQUIRED |
| code | string | Provide the smart contract name | REQUIRED |
| table | string | Provide the table name | REQUIRED |
| json | boolean | return result in JSON format | REQUIRED |
| lower_bound | int32 | Provide the lower bound | / |
| upper_bound | int32 | Provide the upper bound | / |
| limit | int32 | Provide the limit | / |
执行结果:
1 | { |
abi_json_to_bin
将 json 序列化为二进制十六进制。 生成的二进制十六进制通常用于 push_transaction 中的数据字段。
1 | POST http://127.0.0.1:8888/v1/chain/abi_json_to_bin |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| code | string | Provide the account name | / |
| action | string | Provide the action arguments | / |
| args | json | Provide the json arguments | / |
执行结果:
1 | { |
abi_bin_to_json
将二进制十六进制序列化为 json 格式。
1 | POST http://127.0.0.1:8888/v1/chain/abi_bin_to_json |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| code | string | Provide the smart contract account name | REQUIRED |
| action | string | Provide the action name | REQUIRED |
| binargs | string | Provide the binary arguments | REQUIRED |
执行结果:
1 | { |
get_required_keys
返回签署事务所需的密钥。
1 | POST http://127.0.0.1:8888/v1/chain/get_required_keys |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| transaction | json | Provide the transaction object | REQUIRED |
| available_keys | array of strings | Provide the available keys | REQUIRED |
执行结果:
1 | { |
Example
transaction
1 | { |
available_keys
1 | ["EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq", |
get_currency_stats
获取某种资产的详情。
1 | POST http://127.0.0.1:8888/v1/chain/get_currency_stats |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| code | string | / | |
| symbol | string | currency symbol to get the stats for | / |
get_producers
获取生产者信息。
1 | POST http://127.0.0.1:8888/v1/chain/get_producers |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| limit | string | total number of producers to retrieve | / |
| lower_bound | string | / | |
| json | boolean | return result in JSON format? | / |
push_block
推送区块。
1 | POST http://127.0.0.1:8888/v1/chain/push_block |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| timestamp | date-time | / | |
| producer | string | / | |
| confirmed | int32 | / | |
| previous | string | / | |
| transaction_mroot | string | / | |
| action_mroot | int32 | / | |
| version | string | / | |
| new_producers | array of strings | / | |
| header_extensions | array of strings | / | |
| producer_signature | string | / | |
| transactions | array | / | |
| block_extensions | array of strings | / |
push_transaction
此方法需要JSON格式的事务,并尝试将其应用于区块链。
1 | POST http://127.0.0.1:8888/v1/chain/push_transaction |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| signatures | array of strings | array of signatures required to authorize transaction | / |
| compression | string | compression used, usually false | / |
| packed_context_free_data | string | json to hex | / |
| packed_trx | string | json to hex | / |
执行结果:
1 | { |
Example
Note
这里的ref_block_num和ref_block_prefix是last_irreversible_block的/v1/chain/get_block的结果。 可以通过调用/v1/chain/get_info找到last_irreversible_block。 您还需要使用/v1/wallet/sign_transaction来获取正确的签名。
push_transactions
此方法需要JSON格式的事务,并尝试将其应用于区块链。 此方法一次推送多个事务。
1 | POST http://127.0.0.1:8888/v1/chain/push_transaction |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| body | json | Provide the authorizations for the transaction | REQUIRED |
执行结果:
1 | { |
Example
Note
这里的ref_block_num和ref_block_prefix是last_irreversible_block的/v1/chain/get_block的结果。 可以通过调用/v1/chain/get_info找到last_irreversible_block。 您还需要使用/v1/wallet/sign_transaction来获取正确的签名。
HISTORY
注意:需要启用 history-api 插件
get_key_accounts
根据公钥查询账户。
1 | POST http://127.0.0.1:8888/v1/history/get_key_accounts |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | |
|---|---|---|
| public_key | int32 | / |
NET
注意:需要启用 net 插件
connect
1 | POST http://127.0.0.1:8888/v1/net/connect |
示例:
1 | curl --request POST \ |
参数
string
disconnect
1 | POST http://127.0.0.1:8888/v1/net/disconnect |
示例:
1 | curl --request POST \ |
参数
string
connections
1 | POST http://127.0.0.1:8888/v1/net/connections |
示例:
1 | curl --request POST \ |
status
1 | POST http://127.0.0.1:8888/v1/net/status |
示例:
1 | curl --request POST \ |
PRODUCER
需要启用 producer 插件
pause
1 | POST http://127.0.0.1:8888/v1/producer/pause |
示例:
1 | curl --request POST \ |
resume
1 | POST http://127.0.0.1:8888/v1/producer/resume |
示例:
1 | curl --request POST \ |
paused
1 | POST http://127.0.0.1:8888/v1/producer/paused |
示例:
1 | curl --request POST \ |
get_runtime_options
1 | POST http://127.0.0.1:8888/v1/producer/get_runtime_options |
示例:
1 | curl --request POST \ |
update_runtime_options
1 | POST http://127.0.0.1:8888/v1/producer/update_runtime_options |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | |
|---|---|---|
| max_transaction_time | int32 | / |
| max_irreversible_block_age | int32 | / |
| produce_time_offset_us | int32 | / |
| last_block_time_offset_us | int32 | / |
| incoming_defer_ratio | int32 | / |
| subjective_cpu_leeway_us | int32 | / |
get_greylist
1 | POST http://127.0.0.1:8888/v1/producer/get_greylist |
示例:
1 | curl --request POST \ |
执行结果:
1 | {"accounts":["a11111111111","aaa","bbb"]} |
add_greylist_accounts
1 | POST http://127.0.0.1:8888/v1/producer/add_greylist_accounts |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| accounts | array of strings | Accounts to add to greylist | / |
remove_greylist_accounts
1 | POST http://127.0.0.1:8888/v1/producer/remove_greylist_accounts |
示例:
1 | curl --request POST \ |
主体参数
| 参数 | 类型 | 描述 | |
|---|---|---|---|
| accounts | array of strings | Accounts to add to greylist | / |
get_whitelist_blacklist
1 | POST http://127.0.0.1:8888/v1/producer/get_whitelist_blacklist |
示例:
1 | curl --request POST \ |
set_whitelist_blacklist
1 | POST http://127.0.0.1:8888/v1/producer/set_whitelist_blacklist |
示例:
1 | curl --request POST \ |
DBSIZE
get
1 | POST http://127.0.0.1:8888/v1/db_size/get |
示例:
1 | curl --request POST \ |
