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 27, 2018 · 28 revisions

C3 JSON-RPC Specification

List of supported C3 JSON RPC Specification methods

Invoke Method

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

Example success response

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

Example error response

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
     "code": "4002",
     "message": "invalid arguments",
     "data": ""
  }
}

Fork Image

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

TODO

  • c3_block // return block by number
  • c3_headBlockNumber // return latest block number
  • c3_imageStateBlocks // return state blocks for image
  • c3_nodePeerCount // return peer count of node
  • c3_nodePeerList // return peer list of node
  • c3_nodeImageList // return images in node's registry
  • c3_nodeInfo // return info about the node
  • c3_accountBalance // return account balance
  • c3_subscribeEvents // subscribe to events

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