This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
C3 JSON RPC Specification
Adam Hanna edited this page Jul 12, 2018
·
28 revisions
List of supported C3 JSON RPC Specification methods
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_ping"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "pong"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_broadcastTransaction",
"params": [
"serializedTransactionHex": "{hex bytes}" // hex encoded serialized transaction
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "ok"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_broadcastBlock",
"params": [
"serializedBlockHex": "{hex bytes}" // hex encoded serialized main block
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "ok"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_invokeMethod",
"params": [
"myMethodName",
"{payload}"
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "123"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_forkImage",
"params": [
"{imageHash}",
"{stateBlockNumber}"
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "{imageHash}"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_fetchBlock",
"params": [
"{blockNumber}"
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"{block}"
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_fetchStateBlock",
"params": [
"{stateBlockNumber}"
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"{stateBlock}"
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_headBlockNumber"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": 30
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_headBlock"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "[bytes...]"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_listStateBlocks",
"params": [
"{imageHash}",
"{skip}", // optional number of blocks to skip
"{limit}" // optional number of blocks to limit in response
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"{stateBlock}",
"{stateBlock}",
// ...
]
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_nodePeerCount"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": 4
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_listNodePeers"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"{nodePeerIPAddr}",
"{nodePeerIPAddr}",
// ...
]
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_listNodeImages",
"params": [
"{skip}", // optional number of hashes to skip
"{limit}" // optional number of hashes to limit in response
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"{imageHash}",
"{imageHash}",
// ...
]
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_nodeInfo"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"{nodeInfo}" // TBD
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_accountBalance",
"params": "{publicAddress}"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "1000000000000000000"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_subscribeEvents",
"params": "{eventID}"
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"{eventID}",
"data": {
// event specific
}
}
}
to see that image exists
{
"jsonrpc": "2.0",
"id": 1,
"method": "c3_ping",
"params": [
"{imageHash}"
]
}
Example success response
{
"jsonrpc": "2.0",
"id": 1,
"result": "pong"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "method name string",
"params": [
// ...
]
}
{
"jsonrpc": "2.0",
"id": "1",
"{error||result}"
}
- This member is REQUIRED on success.
- This member MUST NOT exist if there was an error invoking the method.
- The value of this member is determined by the method invoked on the Server.
- This member is REQUIRED on error.
- This member MUST NOT exist if there was no error triggered during invocation.
- The value for this member MUST be an Object as defined below
Error codes:
code | message | meaning |
---|---|---|
-32700 | Parse error | Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. |
-32600 | Invalid Request | The JSON sent is not a valid Request object. |
-32601 | Method not found | The method does not exist / is not available. |
-32602 | Invalid params | Invalid method parameter(s). |
-32603 | Internal error | Internal JSON-RPC error. |
-32000 to -32099 | Server error | Reserved for implementation-defined server-errors. |
{
"code": -32700,
"message": "a string message",
"data": {
// ...
}
}