npm-package-near-advanced-receipt
v1.0.0
Published
npm Package - near-advanced-receipt
Readme
npm-package-near-advanced-receipt
Utilities for fetching and analyzing receipts on the NEAR blockchain.
Installation
npm install npm-package-near-advanced-receipt
Functions
getReceipt(receiptId)— Fetch a single receipt by its IDgetReceiptsByTx(txHash, senderAccountId)— Fetch all receipts for a transactiongetReceiptOutcomes(txHash, senderAccountId)— Get execution outcomes for all receiptsdidAllReceiptsSucceed(txHash, senderAccountId)— Check if every receipt succeededgetTotalGasBurned(txHash, senderAccountId)— Sum total gas burned across all receipts
Usage
import { getReceipt, getReceiptsByTx, getReceiptOutcomes, didAllReceiptsSucceed, getTotalGasBurned, } from 'npm-package-near-advanced-receipt';
// Fetch a single receipt const receipt = await getReceipt('ReceiptIdHere');
// Fetch all receipts produced by a transaction const receipts = await getReceiptsByTx('TxHashHere', 'sender.near');
// Get execution outcomes for all receipts in a transaction const outcomes = await getReceiptOutcomes('TxHashHere', 'sender.near');
// Check whether all receipts in a transaction succeeded const allSucceeded = await didAllReceiptsSucceed('TxHashHere', 'sender.near'); console.log(allSucceeded); // true or false
// Get total gas burned across all receipts
const totalGas = await getTotalGasBurned('TxHashHere', 'sender.near');
console.log(Total gas burned: ${totalGas});
Notes
- Targets NEAR mainnet RPC by default (
https://rpc.mainnet.near.org) - All functions are async and return Promises
- Throws an error if the RPC returns an error response
License
MIT
