Liberdus RPC Documentation

This document describes the available RPC methods for interacting with the Liberdus backend. These methods allow developers to perform operations such as sending transactions, retrieving transaction receipts, managing subscriptions, and more.


Methods Overview


lib_send_transaction

Description: Injects a transaction into the Liberdus system with retry logic.

Parameters:

  • params: Stringified Transaction Object.

Returns:

  • Success Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "result": {
            "success": true,
            "txid": "<hash>"
        }
    }
  • Error Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "error": {
            "code": -32600,
            "message": "<error_message>"
        }
    }

Usage Example:

{
    "jsonrpc": "2.0",
    "method": "lib_send_transaction",
    "params": ["{\"to\": \"0x1234...\", \"value\": \"100\"}"],
    "id": 1
}

For more detailed on transaction object, please refer to source code or doc.


lib_get_transaction_receipt

Description: Retrieves the receipt of a specific transaction.

Parameters:

  • params: An array containing the transaction id as a string on the first index.

Returns:

  • Success Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "result": {
          ...
        }
    }
  • Error Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "error": {
            "code": -32600,
            "message": "<error_message>"
        }
    }

Usage Example:

{
    "jsonrpc": "2.0",
    "method": "lib_get_transaction_receipt",
    "params": ["0xdeadbeef...32byte"],
    "id": 1
}

lib_get_transaction_history

Description: Fetches the transaction history for a specific account.

Parameters:

  • params[0] (string): An array containing the account ID as a string on the first index. (32bytes) padded shardus address.

Returns:

  • Success Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "result": {
              <Transaction Receipt>
        }
    }
  • Error Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "error": {
            "code": -32600,
            "message": "<error_message>"
        }
    }

Usage Example:

{
    "jsonrpc": "2.0",
    "method": "lib_get_transaction_history",
    "params": ["0xaccount123"],
    "id": 1
}

lib_get_account

Description: Retrieves account details for a specific address or by alias.

Parameters:

  • params[0]: An array containing the account address as a string. (32bytes) padded shardus address.
  • params[1]: An optional string containing the alias of the account.

If both are supplied alias will be used to fetch the account.

Returns:

  • Success Response:

    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "result": {
          <Account Object>
        }
    }
  • Error Response:

    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "error": {
            "code": -32600,
            "message": "<error_message>"
        }
    }

See more about account object in Account Types

Usage Example:

{
    "jsonrpc": "2.0",
    "method": "lib_get_account",
    "params": ["0xaddress123"],
    "id": 1
}

lib_get_messages

Description: Retrieves chat messages for a specific chat ID.

Parameters:

  • params: An array containing the chat ID as a string. Chat id is blake2 hash of a sorted joint string of two account address alphabetically.

Returns:

  • Success Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "result": [
          <Message Object>,
            ...
        ]
    }
  • Error Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "error": {
            "code": -32600,
            "message": "<error_message>"
        }
    }

Usage Example:

{
    "jsonrpc": "2.0",
    "method": "lib_get_messages",
    "params": ["chatroom123"],
    "id": 1
}

lib_subscribe

Description: Subscribes to a chat room for updates.

Parameters:

  • params: An array containing the chat ID as a string. Chat id is blake2 hash of a sorted joint string of two account address alphabetically.
  • Requires a WebSocket connection.

Returns:

  • Success Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "result": "<subscription_id>"
    }
  • Error Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "error": {
            "code": -32600,
            "message": "<error_message>"
        }
    }

Usage Example:

{
    "jsonrpc": "2.0",
    "method": "lib_subscribe",
    "params": ["0xfefe...."],
    "id": 1
}

lib_unsubscribe

Description: Unsubscribes from a chat room.

Parameters:

  • params: An array containing the subscription ID as a string.

Returns:

  • Success Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "result": true
    }
  • Error Response:
    {
        "jsonrpc": "2.0",
        "id": <request_id>,
        "error": {
            "code": -32600,
            "message": "<error_message>"
        }
    }

Usage Example:

{
    "jsonrpc": "2.0",
    "method": "lib_unsubscribe",
    "params": ["subscription123"],
    "id": 1
}