RPC API

CHAIN

get_info

返回包含區塊鏈的各種詳細信息的對象。

1
POST http://127.0.0.1:8870/v1/chain/get_info

示例:

1
2
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_info

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"server_version": "3f9cb99e",
"chain_id": "fe50c592f3d9b395455ee6499c13e2269cb9cdc9605465c7ba04d4af54cf2e3f",
"head_block_num": 2734,
"last_irreversible_block_num": 2733,
"last_irreversible_block_id": "00000aadcffb23aaf10f4443ea751e2ddac6a164b3a6bad85353eeff4804273a",
"head_block_id": "00000aaeccf1f80bc929c3c00d06917fc72b7b3d7800c934c555425fac0e3eab",
"head_block_time": "2023-02-08T08:30:27.000",
"head_block_producer": "testnetbppa1",
"virtual_block_cpu_limit": 15377472,
"virtual_block_net_limit": 48388672,
"block_cpu_limit": 999999,
"block_net_limit": 3145728,
"server_version_string": "v3.2.1",
"fork_db_head_block_num": 2734,
"fork_db_head_block_id": "00000aaeccf1f80bc929c3c00d06917fc72b7b3d7800c934c555425fac0e3eab",
"server_full_version_string": "v3.2.1-3f9cb99e068da8581036d212d74fb56144ef0fc4",
"total_cpu_weight": "25000002600000",
"total_net_weight": "25000002600000",
"earliest_available_block_num": 1,
"last_irreversible_block_time": "2023-02-08T08:30:26.500"
}

get_code

返回一個包含指定合約wasm的對象

1
POST http://127.0.0.1:8870/v1/chain/get_code

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_code \
--data '{"account_name": "dmc.token","code_as_wasm": 1}'

主體參數

參數 類型 描述
account_name string Provide an account name REQUIRED
code_as_wasm integer 1 REQUIRED

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
"account_name": "dmc.token",
"code_hash": "ef767c5372409a154a4dd0d73c3a819dd0ae481e7e686793f43afdaf060abc1e",
"wast": "",
"wasm": "\u0000asm\u0001\u0000\u0000\u0000\u0001\u0002(`\u0000\u0000`\u0003\u007f\u007f\u007f\u0001\u007f`\u0003\u007f~\u007f\u0001~`\u0004\u007f\u007f\u007f\u007f\u0000`\u0001~\u0000`\u0002\u007f\u007f\u0000`\u0004~~~~\u0001\u007f`\u0000\u0001~`\u0006~~~~\u007f\u007f\u0001\u007f`\u0004\u007f~\u007f\u007f\u0000`......",
"abi": {
"version": "dmc::abi/1.2",
"types": [],
"structs": [
{
"name": "account",
"base": "",
"fields": [
{
"name": "balance",
"type": "asset"
}
]
},
{
"name": "close",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "symbol",
"type": "symbol"
}
]
},
.....
],
"actions": [
{
"name": "close",
"type": "close",
"ricardian_contract": ""
},
{
"name": "create",
"type": "create",
"ricardian_contract": ""
},
....
],
"tables": [
{
"name": "accounts",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "account"
},
{
"name": "stat",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "currency_stats"
}
],
"ricardian_clauses": [],
"error_messages": [],
"abi_extensions": [],
"variants": [],
"action_results": []
}
}

get_block

返回一個對象,其中包含有關區塊鏈上特定塊的各種詳細信息。

1
POST http://127.0.0.1:8870/v1/chain/get_block

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_block \
--data '{"block_num_or_id": "5"}'

主體參數

參數 類型 描述
block_num_or_id string Provide a block number or a block id REQUIRED

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"timestamp": "2023-02-08T08:07:42.500",
"producer": "dmc",
"confirmed": 0,
"previous": "00000004de8874190d8a5b8accfcca633e2ab368fe80b9332ca1142d5cdd3028",
"transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000",
"action_mroot": "d4bbf96f695cc7d244e5589f2c8cccad0f79ca65db6fbea29934e5671d405713",
"schedule_version": 0,
"new_producers": null,
"producer_signature": "SIG_K1_KefzFFP78WL76X6JM8F4UGdeMKHJvmmWHDKdTD2vA3MQEmsJB8xZsVx273kqvp1bQ7WkxWfNew5s6Ygjr8p6RPqNzCjyNc",
"transactions": [],
"id": "00000005c26601e45cb1cef568a2ed9b8827c7ccd054dd50443a871a3cbf5180",
"block_num": 5,
"ref_block_prefix": 4123963740
}

get_block_header_state

獲取可逆區塊頭狀態。

1
POST http://127.0.0.1:8870/v1/chain/get_block_header_state

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_block_header_state \
--data '{"block_num_or_id":"118"}'

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{
"block_num": 533611,
"dpos_proposed_irreversible_blocknum": 533588,
"dpos_irreversible_blocknum": 533564,
"active_schedule": {
"version": 3,
"producers": [
{
"producer_name": "dmcdevbppa11",
"authority": [
0,
{
"threshold": 1,
"keys": [
{
"key": "DM5o7ccNUPgdTdiJvT3ytQ87AkiMmwhLb2VwM9JijFpxn877EyEk",
"weight": 1
}
]
}
]
},
{
"producer_name": "dmcdevbppa12",
"authority": [
0,
{
"threshold": 1,
"keys": [
{
"key": "DM5o7ccNUPgdTdiJvT3ytQ87AkiMmwhLb2VwM9JijFpxn877EyEk",
"weight": 1
}
]
}
]
},
{
"producer_name": "speakfool123",
"authority": [
0,
{
"threshold": 1,
"keys": [
{
"key": "DM6iTKfTV3LmLMcoBAXvfsYnAnHnbztnEDdoswivCvgyHnvTLEmK",
"weight": 1
}
]
}
]
}
]
},
"blockroot_merkle": {
"_active_nodes": [
"10beb144529bf08cdc975bc6a23bbe0269e26cef17d8762b5ec8c8214fef6a2c",
"32402d6b019bb100bdb2e919853282e73cee3f9eba5975142994ee1b438aaf10",
"2d3488d432360c3066eaf295e33af8c749ff0951182c3dc40477e4e2ced1ef90",
"f7e2e5fc90558c82b17f5cbb5e7dc59379a6d0f7f5095600474eadcaf8484165",
"49f4ab6c9245a8f0ac690e28845beee6ca64701817a61b8a4429477f93a81077",
"32e13b99ff6c55522206bc5b22910daf8c1e94c121af45be62c9f05f0dd9cf2a",
"174baa3f5b18dfa06468de5525b1f78b038a9c4b8137a6afbb07fad18684b73d",
"50f9c5a5169167a7c48a51972678af645fae2e151b8a9eaec8903be5d6e98952"
],
"_node_count": 533610
},
"producer_to_last_produced": [
[
"dmcdevbppa11",
533611
],
[
"dmcdevbppa12",
533588
],
[
"speakfool123",
533600
]
],
"producer_to_last_implied_irb": [
[
"dmcdevbppa11",
533588
],
[
"dmcdevbppa12",
533564
],
[
"speakfool123",
533576
]
],
"valid_block_signing_authority": [
0,
{
"threshold": 1,
"keys": [
{
"key": "DM5o7ccNUPgdTdiJvT3ytQ87AkiMmwhLb2VwM9JijFpxn877EyEk",
"weight": 1
}
]
}
],
"confirm_count": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
],
"id": "0008246bca35e3fb110fa13a1fc7c3dfb138c50a02a25f2ed845d20902fd22b0",
"header": {
"timestamp": "2023-06-15T08:08:47.000",
"producer": "dmcdevbppa11",
"confirmed": 0,
"previous": "0008246ab505eb679bde02dc93a45a871b479fa55fa61353dc968c2c100ec3a1",
"transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000",
"action_mroot": "9eb45feeba91070f9a1d9b130175b37fd6075f7eeeea816fd5f544caf600391a",
"schedule_version": 3,
"header_extensions": [],
"producer_signature": "SIG_K1_K8W1Dw7xcVL2TfCSAWpdz1yXgNuRkMEdCyg4SG1D1hFgBMtzmJqDmAdVzB1n4FhyQZM6S2sLnYRiudY4L6rHGvHhULf6A2"
},
"pending_schedule": {
"schedule_lib_num": 765,
"schedule_hash": "de34ff1b7b649601eb74a34c02ba0cff6f6c670c743432ff6e33f4a510a98b5a",
"schedule": {
"version": 3,
"producers": []
}
},
"activated_protocol_features": {
"protocol_features": []
},
"additional_signatures": []
}

主體參數

參數 類型 描述
block_num_or_id string Provide a block number or a block id REQUIRED

get_block_info

返回一個塊數據的固定大小的較小子集,其中包含有關區塊鏈上特定塊的各種詳細信息。

1
POST http://127.0.0.1:8870/v1/chain/get_block_info

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_block_info \
--data '{"block_num": 5}'

主題參數

參數 類型 描述
block_num integer Provide a block num REQUIRED

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"block_num": 5,
"ref_block_num": 5,
"id": "00000005c26601e45cb1cef568a2ed9b8827c7ccd054dd50443a871a3cbf5180",
"timestamp": "2023-02-08T08:07:42.500",
"producer": "dmc",
"confirmed": 0,
"previous": "00000004de8874190d8a5b8accfcca633e2ab368fe80b9332ca1142d5cdd3028",
"transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000",
"action_mroot": "d4bbf96f695cc7d244e5589f2c8cccad0f79ca65db6fbea29934e5671d405713",
"schedule_version": 0,
"producer_signature": "SIG_K1_KefzFFP78WL76X6JM8F4UGdeMKHJvmmWHDKdTD2vA3MQEmsJB8xZsVx273kqvp1bQ7WkxWfNew5s6Ygjr8p6RPqNzCjyNc",
"ref_block_prefix": 4123963740
}

get_account

返回一個對象,其中包含有關區塊鏈上特定帳戶的各種詳細信息。

1
POST http://127.0.0.1:8870/v1/chain/get_account

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_account \
--data '{"account_name": "dmc"}'

主體參數

參數 類型 描述
account_name string Provide an account name REQUIRED

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
"account_name": "dmc",
"head_block_num": 5102,
"head_block_time": "2023-02-08T08:50:11.000",
"privileged": true,
"last_code_update": "2023-02-08T08:07:57.500",
"created": "2022-02-22T22:22:22.000",
"core_liquid_balance": "4999729504.2716 DMC",
"ram_quota": -1,
"net_weight": -1,
"cpu_weight": -1,
"net_limit": {
"used": -1,
"available": -1,
"max": -1,
"last_usage_update_time": "2023-02-08T08:50:11.500",
"current_used": -1
},
"cpu_limit": {
"used": -1,
"available": -1,
"max": -1,
"last_usage_update_time": "2023-02-08T08:50:11.500",
"current_used": -1
},
"ram_usage": 3142372,
"permissions": [
{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [],
"accounts": [
{
"permission": {
"actor": "dmc.prods",
"permission": "active"
},
"weight": 1
}
],
"waits": []
},
"linked_actions": []
},
{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [],
"accounts": [
{
"permission": {
"actor": "dmc.prods",
"permission": "active"
},
"weight": 1
}
],
"waits": []
},
"linked_actions": []
}
],
"total_resources": null,
"self_delegated_bandwidth": null,
"refund_request": null,
"voter_info": null,
"rex_info": null,
"subjective_cpu_bill_limit": {
"used": 0,
"available": 0,
"max": 0,
"last_usage_update_time": "2000-01-01T00:00:00.000",
"current_used": 0
},
"dmc_any_linked_actions": []
}

get_abi

獲取賬戶的 abi 數據。

1
POST http://127.0.0.1:8870/v1/chain/get_abi

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_abi \
--data '{"account_name": "dmc"}'

主體參數

參數 類型 描述
account_name string name of account to retrieve ABI for REQUIRED

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
"account_name": "dmc",
"abi": {
"version": "dmc::abi/1.2",
"types": [
{
"new_type_name": "block_signing_authority",
"type": "variant_block_signing_authority_v0"
}
],
"structs": [
{
"name": "abi_hash",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "hash",
"type": "checksum256"
}
]
},
{
"name": "activate",
"base": "",
"fields": [
{
"name": "feature_digest",
"type": "checksum256"
}
]
},
......
],
"tables": [
{
"name": "abihash",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "abi_hash"
},
{
"name": "bidrefunds",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "bid_refund"
},
{
"name": "cpuloan",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "rex_loan"
},
........
],
"ricardian_clauses": [],
"error_messages": [],
"abi_extensions": [],
"variants": [
{
"name": "variant_block_signing_authority_v0",
"types": [
"block_signing_authority_v0"
]
}
],
"action_results": []
}
}

get_raw_abi

獲取賬戶的原始的abi數據

1
POST http://127.0.0.1:8870/v1/chain/get_raw_abi

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_raw_abi \
--data '{"account_name":"dmc.token"}'

主體參數

參數 類型 描述
account_name string Account name to get code and abi for REQUIRED

執行結果:

1
2
3
4
5
6
{
"account_name": "dmc.token",
"code_hash": "ef767c5372409a154a4dd0d73c3a819dd0ae481e7e686793f43afdaf060abc1e",
"abi_hash": "56a2bc30abd9b93bd6ccaa85bd11e51ecc527b95ae7a5108e635925a19c175db",
"abi": "DmVvc2lvOjphYmkvMS4yAAgHYWNjb3VudAABB2JhbGFuY2UFYXNzZXQFY2xvc2UAAgVvd25lcgRuYW1lBnN5bWJvbAZzeW1ib2wGY3JlYXRlAAIGaXNzdWVyBG5hbWUObWF4aW11bV9zdXBwbHkFYXNzZXQOY3VycmVuY3lfc3RhdHMAAwZzdXBwbHkFYXNzZXQKbWF4X3N1cHBseQVhc3NldAZpc3N1ZXIEbmFtZQVpc3N1ZQADAnRvBG5hbWUIcXVhbnRpdHkFYXNzZXQEbWVtbwZzdHJpbmcEb3BlbgADBW93bmVyBG5hbWUGc3ltYm9sBnN5bWJvbAlyYW1fcGF5ZXIEbmFtZQZyZXRpcmUAAghxdWFudGl0eQVhc3NldARtZW1vBnN0cmluZwh0cmFuc2ZlcgAEBGZyb20EbmFtZQJ0bwRuYW1lCHF1YW50aXR5BWFzc2V0BG1lbW8Gc3RyaW5nBgAAAAAAhWlEBWNsb3NlAAAAAACobNRFBmNyZWF0ZQAAAAAAAKUxdgVpc3N1ZQAAAAAAADBVpQRvcGVuAAAAAACo67K6BnJldGlyZQAAAABXLTzNzQh0cmFuc2ZlcgACAAAAOE9NETIDaTY0AAAHYWNjb3VudAAAAAAAkE3GA2k2NAAADmN1cnJlbmN5X3N0YXRzAAAAAAAA="
}

get_raw_code_and_abi

獲取賬戶的原始 code 和 abi 數據。

1
POST http://127.0.0.1:8870/v1/chain/get_raw_code_and_abi

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_raw_code_and_abi \
--data '{"account_name":"dmc.token"}'

主體參數

參數 類型 描述
account_name string Account name to get code and abi for REQUIRED

執行結果:

1
2
3
4
5
{
"account_name": "dmc.token",
"wasm": "AGFzbQEAAAABgAIoYAAAYAN/f38Bf2ADf35/AX5gBH9/f38AYAF+AGACf38AYAR+fn5+AX9gAAF+YAZ+fn5+f38Bf2AEf35/fwBgAX4Bf2ACf38Bf2AAAX9gAn99AGAFf35+fn4AYAJ/fABgAn5+AXxgAn5+AX1gAn9/AX5gAn9+AGABfwBgA35+fgBgAX8Bf2AEf39/fgF+YAN/f38BfmACfH8BfGACfn4Bf2ABfAF8YAR/fn5/AGACf38BfWACf38BfGADf39/AGACfn8Bf2AFf39/f38Bf2ALf39/f39/f39/f38Bf2AEf39/fwF/YAR/f35/AGAFf39/f38AYAN/fn8Bf2ACfn4AAvAFJwNlbnYMcmVxdWlyZV9hdXRoAAQDZW52DGVvc2lvX2Fzc2VydAAFA2VudgtkYl9maW5kX2k2NAAGA2VudhBjdXJyZW50X3JlY2VpdmVyAAcDZW52BWFib3J0AAADZW52Bm1lbXNldAABA2VudgdtZW1tb3......",
"abi": "DmVvc2lvOjphYmkvMS4yAAgHYWNjb3VudAABB2JhbGFuY2UFYXNzZXQFY2xvc2UAAgVvd25lcgRuYW1lBnN5bWJvbAZzeW1ib2wGY3JlYXRlAAIGaXNzdWVyBG5hbWUObWF4aW11bV9zdXBwbHkFYXNzZXQOY3VycmVuY3lfc3RhdHMAAwZzdXBwbHkFYXNzZXQKbWF4X3N1cHBseQVhc3NldAZpc3N1ZXIEbmFtZQVpc3N1ZQADAnRvBG5hbWUIcXVhbnRpdHkFYXNzZXQEbWVtbwZzdHJpbmcEb3BlbgADBW93bmVyBG5hbWUGc3ltYm9sBnN5bWJvbAlyYW1fcGF5ZXIEbmFtZQZyZXRpcmUAAghxdWFudGl0eQVhc3NldARtZW1vBnN0cmluZwh0cmFuc2ZlcgAEBGZyb20EbmFtZQJ0bwRuYW1lCHF1YW50aXR5BWFzc2V0BG1lbW8Gc3RyaW5nBgAAAAAAhWlEBWNsb3NlAAAAAACobNRFBmNyZWF0ZQAAAAAAAKUxdgVpc3N1ZQAAAAAAADBVpQRvcGVuAAAAAACo67K6BnJldGlyZQAAAABXLTzNzQh0cmFuc2ZlcgACAAAAOE9NETIDaTY0AAAHYWNjb3VudAAAAAAAkE3GA2k2NAAADmN1cnJlbmN5X3N0YXRzAAAAAAAA="
}

get_table_rows

返回包含指定表中行的對象。

1
POST http://127.0.0.1:8870/v1/chain/get_table_rows

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_table_rows \
--data '{"code":"dmc.token","table":"accounts","scope":"dmc"}'

主體參數

參數 類型 描述
scope string Provide the account name REQUIRED
code string Provide the smart contract name REQUIRED
table string Provide the table name REQUIRED
index_position string Provide the index position /
key_type string Provide the type of key /
encode_type string Provide the type of ecoding /
lower_bound int32 Provide the lower bound /
upper_bound int32 Provide the upper bound /
limit int32 Provide the limit /
reverse boolean Provide true or false to reverse the result /
show_payer boolean Provide true or false to show the payer of RAM /

執行結果:

1
2
3
4
5
6
7
{
"rows": [
"9cc002e7782d000004454f5300000000"
],
"more": false,
"next_key": ""
}

get_table_by_scope

獲取表

1
POST http://127.0.0.1:8870/v1/chain/get_table_by_scope

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_table_by_scope \
--data '{"code": "dmc"}}'

主體參數

參數 類型 描述
code string Provide the contract name REQUIRED
table string Provide the table name /
lower_bound string Provide the lower bound /
upper_bound string Provide the upper bound /
limit integer limit number /
reverse boolean true or false /
show_payer boolean true or false /

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"rows": [
{
"code": "dmc",
"scope": "dmc",
"table": "global",
"payer": "dmc",
"count": 1
},
{
"code": "dmc",
"scope": "dmc",
"table": "global2",
"payer": "dmc",
"count": 1
},
.....
],
"more": "testnetbppa1"
}

abi_json_to_bin

將 json 序列化為二進制十六進制。 生成的二進制十六進制通常用於 push_transaction 中的數據字段。

1
POST http://127.0.0.1:8870/v1/chain/abi_json_to_bin

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/abi_json_to_bin \
--data '{"code":"dmc.token","action":"transfer","args":{"from":"testnetbppa1","to":"testnetbppb1","quantity":"1.0000 DMC", "memo":"hi there"}}'

主體參數

參數 類型 描述
code string Provide the account name /
action string Provide the action arguments /
args json Provide the json arguments /

執行結果:

1
2
3
{
"binargs": "104cad27ab99b1ca104ead27ab99b1ca102700000000000004454f5300000000086869207468657265"
}

abi_bin_to_json

將二進制十六進制序列化為 json 格式。

1
POST http://127.0.0.1:8870/v1/chain/abi_bin_to_json

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/abi_bin_to_json \
--data '{"code":"dmc.token","action":"transfer","binargs":"104cad27ab99b1ca104ead27ab99b1ca102700000000000004454f5300000000086869207468657265"}'

主體參數

參數 類型 描述
code string Provide the smart contract account name REQUIRED
action string Provide the action name REQUIRED
binargs string Provide the binary arguments REQUIRED

執行結果:

1
2
3
4
5
6
7
8
{
"args": {
"from": "testnetbppa1",
"to": "testnetbppb1",
"quantity": "1.0000 DMC",
"memo": "hi there"
}
}

get_producers

獲取生產者信息。

1
POST http://127.0.0.1:8870/v1/chain/get_producers

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_producers
--data '"limit": "10","lower_bound": "10","json": true'

主體參數

參數 類型 描述
limit string total number of producers to retrieve REQUIRED
lower_bound string REQUIRED
json boolean return result in JSON format? /

執行結果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"rows": [
{
"owner": "testnetbppa1",
"producer_authority": [
0,
{
"threshold": 1,
"keys": [
{
"key": "DM6VfcJSebsfJvueyuShqjGrG3NeTW6rdrotS6qP5jt8jwmtDVeN",
"weight": 1
}
]
}
],
"url": "",
"total_votes": "0.00000000000000000",
"producer_key": "DM6VfcJSebsfJvueyuShqjGrG3NeTW6rdrotS6qP5jt8jwmtDVeN"
}
],
"total_producer_vote_weight": "0.00000000000000000",
"more": ""
}

get_activated_protocol_features

獲取生產者節點的激活協議特徵

1
POST http://127.0.0.1:8870/v1/chain/get_activated_protocol_features

示例:

1
2
3
4
5
6
7
8
9
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_activated_protocol_features
--data ' "params": {
"lower_bound": 1,
"upper_bound": 1,
"limit": 2,
"search_by_block_num": true,
"reverse": true
}'

主體參數

參數 類型 描述
params object Defines the filters to retreive the protocol features by REQUIRED

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"activated_protocol_features": [
{
"feature_digest": "68dcaa34c0517d19666e6b33add67351d8c5f69e999ca1e37931bc410a297428",
"activation_ordinal": 8,
"activation_block_num": 33,
"description_digest": "2853617cec3eabd41881eb48882e6fc5e81a0db917d375057864b3befbe29acd",
"dependencies": [],
"protocol_feature_type": "builtin",
"specification": [
{
"name": "builtin_feature_codename",
"value": "DISALLOW_EMPTY_PRODUCER_SCHEDULE"
}
]
},
{
"feature_digest": "8ba52fe7a3956c5cd3a656a3174b931d3bb2abb45578befc59f283ecd816a405",
"activation_ordinal": 9,
"activation_block_num": 33,
"description_digest": "2f1f13e291c79da5a2bbad259ed7c1f2d34f697ea460b14b565ac33b063b73e2",
"dependencies": [],
"protocol_feature_type": "builtin",
"specification": [
{
"name": "builtin_feature_codename",
"value": "ONLY_BILL_FIRST_AUTHORIZER"
}
]
}
],
"more": 10
}

get_accounts_by_authorizers

根據賬戶姓名和公鑰,查找所有滿足的賬戶權限

1
POST http://127.0.0.1:8870/v1/chain/get_accounts_by_authorizers

示例:

1
2
3
4
5
6
7
8
9
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/get_accounts_by_authorizers
--data ' "accounts": [
"testnetbppa1"
],
"keys": [
"DM6VfcJSebsfJvueyuShqjGrG3NeTW6rdrotS6qP5jt8jwmtDVeN"
]
}'

主體參數

參數 類型 描述
accounts list List of authorizing accounts and/or actor/permissions REQUIRED
keys list List of authorizing keys REQUIRED

push_block

推送區塊。

1
POST http://127.0.0.1:8870/v1/chain/push_block

示例:

1
2
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/push_block

主體參數

參數 類型 描述
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:8870/v1/chain/push_transaction

示例:

1
2
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/push_transaction

主體參數

參數 類型 描述
signatures array of strings array of signatures required to authorize transaction /
compression boolean compression used, usually false /
packed_context_free_data string json to hex /
packed_trx string json to hex /

執行結果:

1
2
3
{
'transaction_id' = "1..."
}

Example

Note

這裡的ref_block_numref_block_prefixlast_irreversible_block/v1/chain/get_block的結果。 可以通過調用/v1/chain/get_info找到last_irreversible_block。 您還需要使用/v1/wallet/sign_transaction來獲取正確的簽名。

send_transaction

此方法需要JSON格式的交易,並嘗試將其應用於區塊鏈。

1
POST http://127.0.0.1:8870/v1/chain/send_transaction

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/send_transaction \
--data '{"body":transaction}'

主體參數

參數 類型 描述
body json Provide the authorizations for the transaction REQUIRED

執行結果:

1
2
3
{
'transaction_id' = "1..."
}

push_transactions

此方法需要JSON格式的事務,並嘗試將其應用於區塊鏈。 此方法一次推送多個事務。

1
POST http://127.0.0.1:8870/v1/chain/push_transaction

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/chain/push_transaction \
--data '{"body":transaction}'

主體參數

參數 類型 描述
body json Provide the authorizations for the transaction REQUIRED

執行結果:

1
2
3
{
'transaction_id' = "1..."
}

Example

Note

這裡的ref_block_numref_block_prefixlast_irreversible_block/v1/chain/get_block的結果。 可以通過調用/v1/chain/get_info找到last_irreversible_block。 您還需要使用/v1/wallet/sign_transaction來獲取正確的簽名。

TRACE

注意:需要啟用 trace-api 插件

get_block

返回包含指定條件的塊跟蹤對象

1
POST http://127.0.0.1:8801/v1/trace_api/get_block

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8801/v1/trace_api/get_block
--data '"block_num": 5'

主體參數

參數 類型
block_num integer REQUIRED

執行結果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
"id": "000000057a7fd628f5a59e7a0aa5ef5f8395bcc0e97cb1eadba7aad9cf88ec90",
"number": 5,
"previous_id": "000000046a12297f06cbb655e89031ba5fda37ae38e8f0bb85b48052dbfe2cbb",
"status": "irreversible",
"timestamp": "2023-02-07T08:04:15.500Z",
"producer": "dmc",
"transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000",
"action_mroot": "cd2636d147bf2ecb2117190a50f3570318e37faafd2abe8e8e0efc19daa4ab3b",
"schedule_version": 0,
"transactions": [
{
"id": "44fff5c87b74c17931cf1e343a3977bd88353787b3db4cb0b455ca29d03c8f07",
"block_num": 5,
"block_time": "2023-02-07T08:04:15.500",
"producer_block_id": "000000057a7fd628f5a59e7a0aa5ef5f8395bcc0e97cb1eadba7aad9cf88ec90",
"actions": [
{
"global_sequence": 4,
"receiver": "dmc",
"account": "dmc",
"action": "onblock",
"authorization": [
{
"account": "dmc",
"permission": "active"
}
],
"data": "fe84e9560000000000ea3055000000000003c140f017c12a9957b47626bdd88d16799cabdce7d61cfcd30f6aca5b0000000000000000000000000000000000000000000000000000000000000000821cee6ac0274892667c58042caf5922f44b21e1915606908c11c6046a981ee1000000000000",
"return_value": ""
}
],
"status": "executed",
"cpu_usage_us": 1,
"net_usage_words": 0,
"signatures": [],
"transaction_header": {
"expiration": "2023-02-07T08:04:16",
"ref_block_num": 4,
"ref_block_prefix": 1438042886,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0
}
}
]
}

NET

注意:需要啟用 net_api 插件

connections

獲取所有連接的狀態

1
POST http://127.0.0.1:8870/v1/net/connections

示例:

1
2
curl --request POST \
--url http://127.0.0.1:8870/v1/net/connections

PRODUCER

需要啟用 producer_api 插件

get_runtime_options

獲取生產者節點的運行時選項

1
POST http://127.0.0.1:8870/v1/producer/get_runtime_options

示例:

1
2
curl --request POST \
--url http://127.0.0.1:8870/v1/producer/get_runtime_options

create_snapshot

為生產者節點創建快照

1
POST http://127.0.0.1:8870/v1/producer/create_snapshot

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/producer/set_whitelist_blacklist
--data '"next":next'

主體參數

參數 類型
head_block_id string /
head_block_num integer /
head_block_time string /
version integer /
snapshot_name string /

get_integrity_hash

獲取生產者節點的完整hash

1
POST http://127.0.0.1:8870/v1/producer/get_integrity_hash

示例:

1
2
curl --request POST \
--url http://127.0.0.1:8870/v1/producer/get_integrity_hash

get_supported_protocol_features

獲取生產者節點支持的協議特點

1
POST http://127.0.0.1:8870/v1/producer/get_supported_protocol_features

示例:

1
2
3
curl --request POST \
--url http://127.0.0.1:8870/v1/producer/schedule_protocol_feature_activations
--data '"params":params'

主體參數

參數 類型 描述
exclude_disabled boolean Exclude disabled protocol features /
exclude_unactivatable boolean Exclude unactivatable protocol features /