rich-client-js
v1.2.1
Published
Rich_API_client_js is a library which provides abstraction to communicate with Rich_API
Downloads
34
Maintainers
Readme
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
:
|Method|Description|
|:---|:---|
|getBlocks
|filters blocks by identifier|
|getBlockSummaries
|filters block summaries by identifier|
|getBlockHeaders
|filters block headers by identifier|
|getTxnByEventTopic
|filters transactions by event topic|
|getTxnSummariesByEventTopic
| filter transaction summaries by event topic |
|getTxnByStatusCode
|get transactions by status code|
|getTxnSummariesByStatusCode
|filters transaction summaries by status code|
|getTransactions
|filters transactions by identifier|
|getTxnSummariesByIdentifier
|filters transaction summaries by identifier|