Skip to main content

Overview

JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs. JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.

JSON-RPC API

This document explains how to use HyperChain APIs. Most APIs support remote protocols (RPC)

NOTE: APIs available in remote protocols are documented mainly. Rest of APIs will be documented later.

Introduction

In order to work properly with HyperChain, you must follow these instructions:

JSON RPC Standard 2.0

HyperChain uses (by default) the pure JSON RPC 2.0 standard

This means that:

  • Every call MUST include 3 params: {"jsonrpc": "2.0", "method": "XXXX", "id": YYYY}
    • jsonrpc : String value = "2.0"
    • method : String value, name of the method to call
    • id : Integer value
  • Optionally can contain another param called "params" holding an object. Inside we will include params to send to the method
  • If JSON does not have a valid "id" value it will not be processed and rejected without a response.
  • If JSON is not JSON RPC Standard 2.0 compliant, it will be rejected without a response.

HTTP POST Details

All calls will be using HTTP protocol (HTTP 1.1) and passing JSON calls by POST at port 8121.

  • Protocol: HTTP v1.1
  • Http Method: POST
  • Port: 8121(MainNet)/8828(TestNet)

Error codes

JSON-RPC Error codes will be in a JSON-Object in this format:

  • code : Error code
  • message : Human readable error description

List of usual error codes

  • 100 : Internal Error
  • 101 : Not Implemented
  • 1001 : Method Not Found
  • 1002 : Invalid Account
  • 1003 : Invalid Block
  • 1004 : Invalid Operation
  • 1005 : Not Found
  • 1006 : Invalid Signature
  • 1016 : Invalid Data

Example

Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getBlockCount","id":123456}' http://localhost:8121
Response
{"result":154197,"id":"123456","jsonrpc":"2.0"}