SimpleChain Documentation

website·Indexed 33 days ago

https://docs.simplechain.com/

Technical documentation for SimpleChain, covering JSON-RPC specifications, conventions, and API details for versions 2.0.0 and Next.

Tokens
2.8K
Snippets
7
Records
24
Agent score
0%

What's inside SimpleChain

  1. Overview of JSON-RPC 2.0 Protocol

    JSON-RPC 2.0 is a stateless, light-weight remote procedure call (RPC) protocol using JSON as the data format. It is transport agnostic, meaning it can be implemented over HTTP, sockets, or within the same process. It is distinguished from version 1.0 by the presence of a jsonrpc member with the value "2.0".
  2. Overview of JSON-RPC 2.0 Protocol

    JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol that uses JSON as its data format. It is transport agnostic, meaning it can be used over HTTP, sockets, or within the same process. The protocol defines specific data structures for requests and responses to ensure consistent communication between a Client (the origin of Request objects) and a Server (the origin of Response objects).
  3. Send multiple requests using Batching

    To invoke multiple methods simultaneously, the Client may send an Array containing multiple Request objects instead of a single Request object.
  4. Send multiple requests using Batching

    To invoke multiple methods simultaneously, the Client may send a Batch request by wrapping multiple Request objects within a JSON Array.
  5. Execute JSON-RPC batch requests

    To execute multiple requests in a single call, send an Array of Request objects. The server processes these as concurrent tasks and returns an Array of Response objects.

    Key behaviors:

    • Response Mapping: The client must match Request objects to Response objects using the id member, as responses may be returned in any order.
    • Notifications: Requests that are notifications (missing an id) must not have a corresponding Response object in the returned array.
    • Error Handling: If the batch call is not valid JSON or is an empty Array, the server returns a single Response object. If the batch contains invalid Request objects, the server returns a Response object for each invalid request.
    • Empty Results: If no Response objects are generated (e.g., a batch of only notifications), the server must return nothing rather than an empty Array.
    --> [
        {"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"},
        {"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},
        {"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"},
        {"foo": "boo"}
    ]
    <-- [
        {"jsonrpc": "2.0", "result": 7, "id": "1"},
        {"jsonrpc": "2.0", "result": 19, "id": "2"},
        {"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request"}, "id": null}
    ]
  6. Send a JSON-RPC Notification

    A Notification is a Request object that does not include an id member. This signifies that the Client is not interested in a response. The Server MUST NOT reply to a Notification, even if it is part of a batch request. Because there is no response, the Client will not be notified of errors such as "Invalid params" or "Internal error".
  7. Handle JSON-RPC 2.0 batch requests

    A batch request is sent as an Array of Request objects. The server processes these and responds with an Array of corresponding Response objects.

    Key behaviors:

    • Order: The server may process requests concurrently and return responses in any order. The client must use the id member to match requests to responses.
    • Notifications: Requests without an id are notifications and MUST NOT have a corresponding response object in the returned array.
    • Validation: If the batch call is not valid JSON or not an Array with at least one value, the server MUST return a single Response object instead of an array.
    • Empty Results: If the resulting response array contains no objects (e.g., all requests were notifications), the server MUST NOT return an empty array; it should return nothing.
  8. Handle JSON-RPC notifications

    A notification is a Request object without an id member. The server must not send a response for notifications.
    --> {"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]}
    // No response is returned
  9. Send a JSON-RPC Notification

    A Notification is a Request object that does not include an id member. This signifies that the Client is not interested in a response. The Server MUST NOT reply to a Notification, and the Client will not be notified of any errors (such as "Invalid params" or "Internal error").
  10. Structure a JSON-RPC 2.0 Response object

    The Server replies to a Request (except Notifications) with a Response object containing:

    • jsonrpc: MUST be exactly "2.0".
    • id: MUST match the id from the Request object. If the id could not be detected (e.g., parse error), it MUST be Null.
    • result: REQUIRED on success. MUST NOT exist if there was an error.
    • error: REQUIRED on error. MUST NOT exist if the call was successful. This must be an Error object.
  11. Define parameters in a JSON-RPC Request

    Parameters in the params member must be provided as a Structured value using one of two methods:

    • By-position: params is an Array containing values in the order expected by the Server.
    • By-name: params is an Object where member names match the Server's expected parameter names (case-sensitive).
  12. Handle JSON-RPC 2.0 Error objects

    When an error occurs, the error member of the Response object must be an Object containing:

    • code: An integer indicating the error type.
    • message: A short, single-sentence description of the error.
    • data: (Optional) Additional information about the error defined by the Server.

    Reserved Error Codes:

    • -32700: Parse error (Invalid JSON received).
    • -32600: Invalid Request (Not a valid Request object).
    • -32601: Method not found.
    • -32602: Invalid params.
    • -32603: Internal error.
    • -32000 to -32099: Implementation-defined server errors.