1.2.1 • Published 1 year ago

rich-client-js v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

ParallelChain F Rich API JavaScript Client Library (pchain-client-js).

This crate is a library that wraps networked interactions with ParallelChain F Rich APIs so that user code does not have to manually produce request bodies and hit HTTP endpoints.

Usage Example

    let client = new RichAPIClient("http://node.digitial-transaction.net");

Methods

RichAPIClient implements methods which queries blockchain information by sending HTTP request to the Rich API endpoint.

Blocks

    let order = "asc";
    let block_hash = "2jdtP11Mco8Fk1zwzl1Ivi5q1wnyRrUT0d6CfSHA3kY";
    let tx_hash = "c72Q4KpwDFVsRurgD_U_rzYi_A05qvZHM8Qma4nyfyc";
    let block_height = 451;

    let blocks = await rich_api_client.blocks.get_blocks("block_number", block_height.toString(), 5, order);
    println!(blocks);
    
    // Output 
    [
      {
        "header": {
          "app_id": 0,
          "block_hash": "EWPT6rZ7wvttVMkJK9QCYyAbpGQw9fWUD9YaDeZTC9k",
          "height": 0,
          "justify": {
            "view_number": 0,
            "block_hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "sigs": {
              "signatures": [
                null,
                null,
                null,
                null
              ],
              "count_some": 0
            }
          },
          "data_hash": "DzqBDlw4PuQWq_0TsMKCs0WxuPmhJwgMPBU-IrylVIo",
          "version_number": 0,
          "timestamp": 1672531200,
          "txs_hash": "B-6jdrGxeH-2BXunZVwh5oOE4Wjk4UPM4xO9LKqzgIk",
          "state_hash": "nWM0MM310GhtsTbAsiy36NhA5VoR7moGZIPfCYXqAGE",
          "receipts_hash": "BmgP8vssG41IAfsU9f7BskmNeY64IiYpzJvfDruLGtI"
        },
        "transactions": [
          {
            "from_address": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "to_address": "v7d8cqWDNt4uqpsSO1mDsK5KFnzmoC07k_uk6j7WSMc",
            "value": 100000000000000000,
            "tip": 0,
            "gas_limit": 0,
            "gas_price": 0,
            "data": "",
            "n_txs_on_chain_from_address": 0,
            "hash": "du4tRb5NGd1Mz_vR0n5iampNwe2D7zduVls7ap_UeBg",
            "signature": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
          },
          {
            "from_address": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "to_address": "YESSKvjZvHI9MH_RMMLsqrSBoHZ_56OA5IMsCwpu8lQ",
            "value": 100000000000000000,
            "tip": 0,
            "gas_limit": 0,
            "gas_price": 0,
            "data": "",
            "n_txs_on_chain_from_address": 0,
            "hash": "_66srKnRx9o4WzN9aREIW467BpEwLkJbp_xFtb2bRQo",
            "signature": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
          }
        ],
        "receipts": [
          {
            "status_code": 0,
            "gas_consumed": 0,
            "return_value": [],
            "events": []
          },
          {
            "status_code": 0,
            "gas_consumed": 0,
            "return_value": [],
            "events": []
          }
        ]
      }
    ]

Transactions

    let order = "asc".to_string();
    let tx_hash = "c72Q4KpwDFVsRurgD_U_rzYi_A05qvZHM8Qma4nyfyc";

    const txn_status_code = await richAPI.transactions.getTxnByStatusCode('latest', 'true', 0, 'all', 1, 'asc')
    println!(txn_status_code);

    // Output 
    {
      "transactions": [{
            "tx_num": 2,
            "transaction": {
            "from_address": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "to_address": "YESSKvjZvHI9MH_RMMLsqrSBoHZ_56OA5IMsCwpu8lQ",
            "value": 100000000000000000,
            "tip": 0,
            "gas_limit": 0,
            "gas_price": 0,
            "data": "",
            "n_txs_on_chain_from_address": 0,
            "hash": "_66srKnRx9o4WzN9aREIW467BpEwLkJbp_xFtb2bRQo",
            "signature": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
            },
            "receipt": {
            "status_code": 0,
            "gas_consumed": 0,
            "return_value": [],
              "events": []
          }
        }]
    }

    const public_address = 'YESSKvjZvHI9MH_RMMLsqrSBoHZ_56OA5IMsCwpu8lQ';
    let filter_map = new Map();
    filter_map.set("to_address", public_address)
    const txs = await richAPI.transactions.getTransactions('latest', 'true', filter_map, 'all', 1, 'asc')
    console.log(txs);

    // Output 
    {
        "transactions": [
        {
            "tx_num": 2,
            "transaction": {
            "from_address": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "to_address": "YESSKvjZvHI9MH_RMMLsqrSBoHZ_56OA5IMsCwpu8lQ",
            "value": 100000000000000000,
            "tip": 0,
            "gas_limit": 0,
            "gas_price": 0,
            "data": "",
            "n_txs_on_chain_from_address": 0,
            "hash": "_66srKnRx9o4WzN9aREIW467BpEwLkJbp_xFtb2bRQo",
            "signature": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
            },
            "receipt": {
            "status_code": 0,
            "gas_consumed": 0,
            "return_value": [],
            "events": []
            }
        }
    ]
    }

Summary of methods provided by RichAPIClient:

MethodDescription
getBlocksfilters blocks by identifier
getBlockSummariesfilters block summaries by identifier
getBlockHeadersfilters block headers by identifier
getTxnByEventTopicfilters transactions by event topic
getTxnSummariesByEventTopicfilter transaction summaries by event topic
getTxnByStatusCodeget transactions by status code
getTxnSummariesByStatusCodefilters transaction summaries by status code
getTransactionsfilters transactions by identifier
getTxnSummariesByIdentifierfilters transaction summaries by identifier
1.2.1

1 year ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago