-
Notifications
You must be signed in to change notification settings - Fork 149
JSON RPC
Table of Contents generated with DocToc
- JSON RPC API
JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol.
CovenantSQL provides a suite of RPC methods in JSON-RPC 2.0 for easily accessing to CovenantSQL networks.
cql.js is a Javascript SDK which has encapsulated the RPC methods in order to give a much more convenient way to talk to the CovenantSQL networks. See the Javascript API for more.
| Network | Provider | URL |
|---|---|---|
| CovenantSQL Test Network | Covenant Labs | https://jsonrpc.testnet.covenantsql.io |
| CovenantSQL Main Network | Covenant Labs | Comming soon :) |
Returns the current CovenantSQL protocol version.
None.
- string - the current CovenantSQL protocol version
Request:
{
"jsonrpc": "2.0",
"method": "bp_getProtocolVersion",
"params": [],
"id": 1
}Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0.1.0"
}Returns some basic indicators describing the running status of the CovenantSQL network.
None.
- object: an object describes the running status of the network.
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "bp_getRunningStatus",
"params": []
}Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"block_height": 182414, // height of the latest block
"count_accounts": 103, // count of the accounts ever created
"count_databases": 912414, // count of the databases ever created
"qps": 10241 // estimated QPS of database operations of the whole net
}
}Returns a list of the blocks.
| Position | Name | type | Description | Sample |
|---|---|---|---|---|
| 0 | from | integer | start height, included | 1 |
| 1 | to | integer | end height, excluded | 11 |
Constraints: to - from ∈ [5, 100]
- array: list of the blocks, the object in the list is a Block, but without transaction details
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "bp_getBlockList",
"params": [1, 11]
}Response: Block array
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{ TODO: block object }
]
}TODO: as a new API in the next release
Returns information about the block specified by its height.
| Position | Name | type | Description | Sample |
|---|---|---|---|---|
| 0 | height | integer | height of the block | 1024 |
| 1 | fetch_transactions | boolean | fetch transactions or not, if false, transactions field in the response will be an empty list |
true |
- object: block information object, it's a Block
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "bp_getBlockByHeight",
"params": [1, true]
}Response: Block
{
"jsonrpc": "2.0",
"id": 1,
"result": {
TODO: block object
}
}Returns information about the block specified by its hash.
| Position | Name | type | Description | Sample |
|---|---|---|---|---|
| 0 | hash | string | hash of the block | "TODO" |
| 1 | fetch_transactions | boolean | fetch transactions or not, if false, transactions field in the response will be an empty list |
true |
- object: block information object, it's a Block
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "bp_getBlockByHash",
"params": ["TODO", true]
}Response: Block
{
"jsonrpc": "2.0",
"id": 1,
"result": {
TODO: block object
}
}Returns a list of the transactions. Traverse page by page by using a transaction hash as the mark for paging.
| Position | Name | type | Description | Sample |
|---|---|---|---|---|
| 0 | since | string | hash as the start point of traverse | "TODO" |
| 1 | direction | string | traverse direction, "backward" or "forward" | "backward" |
| 2 | size | integer | page size, [5, 100] | 20 |
QhcAe42Xf8cwGUf5NYGQDQ
XNZ9yipFBUV5ySBtreW1MA ↑ forward (in newer blocks)
9fXd3s5HE5fC8lOYY6uAZA
KhytGjS0xjw5CJvcJYpsNg ← since (paging mark)
2KOxrKMS4iVDKXnm6HuYiA
71VwqOMOvAsBXJRMeBruWg ↓ backward (in older blocks)
0P3k04RKHw8SEMKHxADC8A
- array: list of the transactions, the object in the list is a Transaction
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "bp_getTransactionList",
"params": ["KhytGjS0xjw5CJvcJYpsNg", "forward", 10]
}Response: Transaction array
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{ TODO: transaction object }
]
}Returns information about the transaction specified by its hash.
| Position | Name | type | Description | Sample |
|---|---|---|---|---|
| 0 | hash | string | hash of the transaction | "TODO" |
- object: transaction information object, it's a Transaction
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "bp_getTransactionByHash",
"params": ["TODO", true]
}Response: Transaction
{
"jsonrpc": "2.0",
"id": 1,
"result": {
TODO: transaction object
}
}Here are some common structure definitions used in the API.
The block generated in the CovenantSQL blockchain network.
| Field | Type | Description |
|---|---|---|
| version | integer | Version number of the block |
| producer | string | Address of the node who generated this block |
| merkle_root | string | Hash of the merkle tree |
| parent | string | Hash of its parent block |
| timestamp | string | Create time of the block |
| hash | string | Hash of the block |
| signee | string | Public key of the node who signed this block |
| signature | string | Signature for the this block |
| height | integer | Height of the block |
| count_tranasctions | integer | Count of the transactions in this block |
| transactions | array | Array of Transaction |
Sample in JSON format:
{
"version": 1,
"producer": "4io8u9v9nydaQPXtmqibg8gJbkNFd7DdM47PLWuM7ubzBXZ4At7",
"merkle_root": "TODO",
"parent": "TODO",
"timestamp": "TODO",
"hash": "TODO",
"signee": "TODO",
"signature": "TODO",
"height": 12,
"count_tranasctions": 1,
"transactions": [
{
"hash": "TODO",
"signee": "TODO"
}
]
}| Field | Type | Description |
|---|---|---|
| hash | string | Hash of the transaction data |
| signee | string | Public key of the account who signed this transaction |
| address | string | Account address who signed this transaction |
| signature | string | Signature of this transaction |
| timestamp | string | Create time of the transaction |
| tx_type | integer | Type of the transaction |
| raw | string | Raw content of the transaction data, in JSON format |
| tx | object | Concrete transaction object, see supported transaction types for more |
| block_height | integer | Height of the block this transaction belongs to |
| block_hash | string | Hash of the block this transaction belongs to |
| index | integer | Index of the transaction in the block |
Sample in JSON format:
{
"hash": "TODO",
"signee": "TODO",
"address": "TODO",
"signature": "TODO",
"timestamp": "TODO",
"tx_type": 1,
"raw": "TODO",
"tx": {
"field": "TODO"
},
"block_height": 1,
"block_hash": "TODO"
}TODO: more types
TODO: more types
