Newer
Older
Method: `erisdb.getConsensusState`
Parameter: -
#####Return value
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
{
height: <number>
round: <number>
step: <number>
start_time: <string>
commit_time: <string>
validators: [<Validator>]
proposal: {
height: <number>
round: <number>
block_parts: {
total: <number>
hash: <string>
}
pol_parts: {
total: <number>
hash: <string>
}
signature: <string>
}
}
```
#####Additional info
TODO
See the GetValidators method right below for info about the `Validator` object.
***
<a name="get-validators"></a>
####GetValidators
Get the validators.
#####HTTP
Method: GET
Endpoint: `/consensus/validators`
#####JSON-RPC
Method: `erisdb.getValidators`
Parameter: -
#####Return value
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
{
block_height: <number>
bonded_validators: [<Validator>]
unbonding_validators: [<Validator>]
}
```
The `Validator` object:
```
{
address: <string>
pub_key: <PubKey>
bon_height: <number>
unbond_height: <number>
last_commit_height: <number>
voting_power: <number>
accum: <number>
}
```
#####Additional info
TODO
***
<a name="events"></a>
###Events
***
<a name="event-subscribe"></a>
####EventSubscribe
Subscribe to a given type of event.
#####HTTP
Method: POST
Endpoint: `/event_subs/`
Body: See JSON-RPC parameter.
#####JSON-RPC
Method: `erisdb.eventSubscribe`
Parameter:
{
event_id: <string>
}
```
#####Return value
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
{
sub_id: <string>
}
```
#####Additional info
For more information about events and the event system, see the [Event system](#event-system) section.
***
<a name="event-unsubscribe"></a>
####EventUnubscribe
Unsubscribe to an event type.
#####HTTP
Method: DELETE
Endpoint: `/event_subs/:id`
#####JSON-RPC
Method: `erisdb.eventUnsubscribe`
Parameter: -
#####Return value
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
{
result: <bool>
}
```
#####Additional info
For more information about events and the event system, see the [Event system](#event-system) section.
***
<a name="event-poll"></a>
####EventPoll
Poll a subscription. Note this cannot be done if using websockets, because then the events will be passed automatically over the socket.
#####HTTP
Method: GET
Endpoint: `/event_subs/:id`
#####JSON-RPC
Method: `erisdb.eventPoll`
#####Return value
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
{
events: [<Event>]
}
```
#####Additional info
For more information about events and the event system, see the [Event system](#event-system) section. This includes info about the `Event` object.
***
<a name="network"></a>
###Network
***
<a name="get-network-info"></a>
####GetNetworkInfo
Get the network information. This includes the blockchain client moniker, peer data, and other things.
#####HTTP
Method: GET
Endpoint: `/network`
#####JSON-RPC
Method: `erisdb.getNetworkInfo`
Parameters: -
#####Return value
moniker: <string>
listening: <boolean>
listeners: [<string>]
peers: [<Peer>]
}
```
#####Additional info
`client_version` is the version of the running client, or node.
`moniker` is a moniker for the node.
`listening` is a check if the node is listening for connections.
`listeners` is a list of active listeners.
`peers` is a list of peers.
See [GetPeer](#get-peer) for info on the `Peer` object.
***
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
<a name="get-client-version"></a>
####GetClientVersion
Get the version of the running client (node).
#####HTTP
Method: GET
Endpoint: `/network/client_version`
#####JSON-RPC
Method: `erisdb.getClientVersion`
Parameters: -
#####Return value
```
{
client_version: <string>
}
```
***
<a name="get-moniker"></a>
####GetMoniker
Get the node moniker, or nickname.
#####HTTP
Method: GET
Endpoint: `/network/moniker`
#####JSON-RPC
Method: `erisdb.getMoniker`
Parameters: -
#####Return value
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
{
moniker: <string>
}
```
***
<a name="is-listening"></a>
####IsListening
Check whether or not the node is listening for connections.
#####HTTP
Method: GET
Endpoint: `/network/listening`
#####JSON-RPC
Method: `erisdb.isListening`
Parameters: -
#####Return value
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
{
listening: <boolean>
}
```
***
<a name="get-listeners"></a>
####GetListeners
Get a list of all active listeners.
#####HTTP
Method: GET
Endpoint: `/network/listeners`
#####JSON-RPC
Method: `erisdb.getListeners`
Parameters: -
#####Return value
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
{
listeners: [<string>]
}
```
***
<a name="get-peers"></a>
####GetPeers
Get a list of all peers.
#####HTTP
Method: GET
Endpoint: `/network/peers`
#####JSON-RPC
Method: `erisdb.getPeers`
Parameters: -
#####Return value
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
{
peers: [<Peer>]
}
```
See [GetPeer](#get-peer) below for info on the `Peer` object.
***
<a name="get-peer"></a>
####GetPeer
Get the peer with the given IP address.
#####HTTP
Method: GET
Endpoint: `/network/peer/:address`
#####JSON-RPC
Method: `erisdb.getPeer`
Parameters:
{
address: <string>
}
```
#####Return value
This is the peer object.
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
{
is_outbound: <boolean>
moniker: <string>
chain_id: <string>
version: <string>
host: <string>
p2p_port: <number>
rpc_port: <number>
}
```
#####Additional info
TODO
***
<a name="transactions"></a>
###Transactions
***
####BroadcastTx
Broadcast a given (signed) transaction to the node. It will be added to the tx pool if there are no issues, and if it is accepted by all validators it will eventually be committed to a block.
#####HTTP
Method: POST
Endpoint: `/txpool`
Body:
<Tx>
```
#####JSON-RPC
Method: `erisdb.BroadcastTx`
Parameters:
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
{
tx_hash: <string>
creates_contract: <number>
contract_addr: <string>
}
```
#####Additional info
`tx_hash` is the hash of the transaction (think digest), and can be used to reference it.
`creates_contract` is set to `1` if a contract was created, otherwise it is 0.
If a contract was created, then `contract_addr` will contain the address. NOTE: This is no guarantee that the contract will actually be commited to the chain. This response is returned upon broadcasting, not when the transaction has been committed to a block.
See [The transaction types](#the-transaction-types) for more info on the `Tx` types.
***
<a name="get-unconfirmed-txs"></a>
####GetUnconfirmedTxs
Get a list of transactions currently residing in the transaction pool. These have been admitted to the pool, but has not yet been committed.
#####HTTP
Method: GET
Endpoint: `/txpool`
#####JSON-RPC
Method: `erisdb.getUnconfirmedTxs`
Parameters: -
#####Return value
{
txs: [<Tx>]
}
```
#####Additional info
See [The transaction types](#the-transaction-types) for more info on the `Tx` types.
***
<a name="calls"></a>
###Code execution (calls)
***
####Call
Call a given (contract) account to execute its code with the given in-data.
#####HTTP
Method: POST
Endpoint: `/calls`
Body: See JSON-RPC parameter.
#####JSON-RPC
Method: `erisdb.call`
Parameters:
{
address: <string>
data: <string>
}
```
#####Return value
{
return: <string>
gas_used: <number>
}
```
#####Additional info
`data` is a string of data formatted in accordance with the [contract ABI](TODO).
***
<a name="call-code"></a>
####CallCode
Pass contract code and tx data to the node and have it executed in the virtual machine. This is mostly a dev feature.
#####HTTP
Method: POST
Body: See JSON-RPC parameter.
#####JSON-RPC
Method: `erisdb.callCode`
Parameters:
{
code: <string>
data: <string>
}
```
#####Return value
{
return: <string>
gas_used: <number>
}
```
#####Additional info
`code` is a hex-string representation of compiled contract code.
`data` is a string of data formatted in accordance with the [contract ABI](TODO).
***
<a name="unsafe"></a>
###Unsafe
These methods are unsafe because they require that a private key is either transmitted or received. They are supposed to be used mostly in development/debugging, and should normally not be used in a production environment.
***
####SignTx
Send an unsigned transaction to the node for signing.
#####HTTP
Method: POST
Endpoint: `/unsafe/tx_signer`
Body:
<Tx>
```
#####JSON-RPC
Method: `erisdb.SignTx`
Parameters:
<Tx>
```
#####Return value
The same transaction but signed.
#####Additional info
See [The transaction types](#the-transaction-types) for more info on the `Tx` types.
***
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
####Transact
Convenience method for sending a transaction "old Ethereum dev style". It will do the following things:
* Use the private key to create a private account object (i.e. generate public key and address).
* Use the other parameters to create a `CallTx` object.
* Sign the transaction.
* Broadcast the transaction.
#####HTTP
Method: POST
Endpoint: `/unsafe/txpool`
Body: See JSON-RPC parameters.
#####JSON-RPC
Method: `erisdb.SignTx`
Parameters:
{
priv_key: <PrivKey>
data: <string>
address: <string>
fee: <number>
gas_limit: <number>
}
```
#####Return value
The same as with BroadcastTx:
{
tx_hash: <string>
creates_contract: <number>
contract_addr: <string>
}
```
#####Additional info
See [The transaction types](#the-transaction-types) for more info on the `CallTx` type.
***
####GenPrivAccount
Convenience method for generating a `PrivAccount` object, which contains a private key and the corresponding public key and address.
#####HTTP
Method: POST
Endpoint: `/unsafe/pa_generator`
#####JSON-RPC
Method: `erisdb.genPrivAccount`
Parameters: -
#####Return value
{
address: <string>
pub_key: <PubKey>
priv_key: <PrivKey>
}
```
#####Additional info
TODO fix endpoint and method.
Again - This is unsafe. Be warned.
***
Filters are used in searches. The structure is similar to that of the [Github api (v3)](https://developer.github.com/v3/search/).
###JSON-RPC
Filters are added as objects in the request parameter. Methods that supports filtering includes an array of filters somewhere in their params object.
Filter:
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
}
```
* The `field` must be one that is supported by the collection items in question.
* The `op` is a relational operation `[>, <, >=, <=, ==, !=]`. Different fields supports different subsets.
* The `value` is the value to match against. It is always a string.
* Range queries are done simply by adding two filters - one for the minimum value and one for the maximum.
#####Examples
We want an account filter that only includes accounts that has code in them (i.e. contract accounts):
```
{
field: "code"
op: "!="
value: ""
}
```
We want an account filter that only includes accounts with a balance less then 1000:
```
{
field: "balance"
op: "<"
value: "1000"
}
```
We want an account filter that only includes accounts with a balance higher then 0, but less then 1000.
```
{
field: "balance"
op: ">"
value: "0"
}
```
```
{
field: "balance"
op: "<"
value: "1000"
}
```
The field `code` is supported by accounts. It allows for the `==` and `!=` operators. The value `""` means the empty hex string.
If we wanted only non-contract accounts then we would have used the same object but changed it to `op: "=="`.
###HTTP Queries
The structure of a normal query is: `q=field:[op]value+field2:[op2]value2+ ... `.
- `field` is the field name.
- `:` is the field-statement separator.
- `op` is the relational operator, `>, <, >=, <=, ==, !=`.
- `value` is always a string value, e.g. `balance:>=5` or `language:==golang`.
There is also support for [range queries](https://help.github.com/articles/search-syntax/): `A..B`, where `A` and `B` are number-strings. You may use the wildcard `*` instead of a number. The wildcard is context-sensitive; if it is put on the left-hand side it is the minimum value, and on the right-hand side it means the maximum value. Let `height` be an unsigned byte with no additional restrictions. `height:*..55` would then be the same as `height:0..55`, and `height:*..*` would be the same as `height:0..255`.
NOTE: URL encoding applies as usual. Omitting it here for clarity.
`op` will default to (`==`) if left out, meaning `balance:5` is the same as `balance:==5`
`value` may be left out if the field accepts the empty string as input. This means if `code` is a supported string type, `code:==` would check if the code field is empty. We could also use the inferred `==` meaning this would be equivalent: `code:`. The system may be extended so that the empty string is automatically converted to the null-type of the underlying field, no matter what that type is. If balance is a number then `balance:` would be the same as `balance:==0` (and `balance:0`).
#####Example
We want to use the same filter as in the JSON version; one that finds all contract accounts.
One that finds non-contract accounts with 0 <= balance <= 1000: