TransactionUtils
@human-protocol/sdk • Docs
@human-protocol/sdk / transaction / TransactionUtils
Class: TransactionUtils
Constructors
new TransactionUtils()
new TransactionUtils():
TransactionUtils
Returns
Methods
getTransaction()
staticgetTransaction(chainId,hash):Promise<ITransaction>
This function returns the transaction data for the given hash.
Parameters
• chainId: ChainId
The chain ID.
• hash: string
The transaction hash.
Returns
Promise<ITransaction>
Returns the transaction details.
Code example
import { TransactionUtils, ChainId } from '@human-protocol/sdk';
const transaction = await TransactionUtils.getTransaction(ChainId.POLYGON, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');Source
getTransactions()
staticgetTransactions(filter):Promise<ITransaction[]>
This function returns all transaction details based on the provided filter.
This uses Subgraph
Input parameters
interface ITransactionsFilter {
networks: ChainId[]; // List of chain IDs to query.
fromAddress?: string; // (Optional) The address from which transactions are sent.
toAddress?: string; // (Optional) The address to which transactions are sent.
startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
startBlock?: number; // (Optional) The start block number to filter transactions (inclusive).
endBlock?: number; // (Optional) The end block number to filter transactions (inclusive).
}type ITransaction = {
block: number;
txHash: string;
from: string;
to: string;
timestamp: number;
value: string;
method: string;
};Parameters
• filter: ITransactionsFilter
Filter for the transactions.
Returns
Promise<ITransaction[]>
Returns an array with all the transaction details.
Code example
import { TransactionUtils, ChainId } from '@human-protocol/sdk';
const filter: ITransactionsFilter = {
networks: [ChainId.POLYGON],
startDate: new Date('2022-01-01'),
endDate: new Date('2022-12-31')
};
const transactions = await TransactionUtils.getTransactions(filter);Source
Last updated