Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

C3 JSON RPC Specification

Adam Hanna edited this page Jun 30, 2018 · 28 revisions

C3 Specification

List of supported C3 JSON RPC Specification methods

Ping

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_ping"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "pong"
}

Ping

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_ping"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "pong"
}

Broadcast Transaction

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_broadcastTransaction",
  "params": [
     "transaction": [2, 47, 244, 0, ..., 8] // serialized transaction
  ]
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "ok"
}

Broadcast Block

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_broadcastBlock",
  "params": [
     "block": [2, 47, 244, 0, ..., 8] // serialized main block
  ]
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "ok"
}

Invoke Method

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_invokeMethod",
  "params": [
     "myMethodName",
     "arg1",
     "arg2"
  ]
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "123"
}

Fork Image

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_forkImage",
  "params": [
     "{imageHash}",
     "{stateBlockNumber}"
  ]
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "{imageHash}"
}

Fetch Block

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_fetchBlock",
  "params": [
     "{blockNumber}"
  ]
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "{block}"
  }
}

Fetch State Block

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_fetchStateBlock",
  "params": [
     "{stateBlockNumber}"
  ]
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "{stateBlock}"
  }
}

Head Block Number

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_headBlockNumber"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": 30
}

Fetch State Blocks For Image

{
  "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}",
    // ...
  ]
}

Node Peer Count

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_nodePeerCount"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": 4
}

List Node Peers

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_listNodePeers"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    "{nodePeerIPAddr}",
    "{nodePeerIPAddr}",
    // ...
  ]
}

List Node Images

{
  "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}",
    // ...
  ]
}

Node Info

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_nodeInfo"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "{nodeInfo}" // TBD
  }
}

Account Balance

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_accountBalance",
  "params": "{publicAddress}"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "1000000000000000000"
}

Subscribe to Events

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "c3_subscribeEvents",
  "params": "{eventID}"
}

Example success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "{eventID}",
    "data": {
      // event specific
    }
  }
}

Ping

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"
}

Generic JSON RPC Spec

Request Object

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "method name string",
  "params": [
     // ...
  ]
}

Response Object

{
  "jsonrpc": "2.0",
  "id": "1",
  "{error||result}"
}

Result Object

  • 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.

Error Object

  • 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": {
    // ...
  }
}
Clone this wiki locally