Appearance
Utilities
Tx Related Functions
Below are transaction related utitility functions that are used prepare txBytes and signing a transaction.
prepareTxData ( contract:
ethers.Contract
, method:string
, args:any[]
, signerAddress:string
, provider:ethers.Provider
, memo?:string
) ⇒Promise<TransactionRequest>
Prepares transaction data for a given smart contract method call
prepareEthTransferTxData ( fromAddress:
string
, toAddress:string
, amountEther:string
, provider:ethers.Provider
) ⇒Promise<TransactionRequest>
Prepares transaction data for transferring Ether between addresses
retrieveMemoFromTxHash ( contract:
ethers.Contract
, txHash:string
, provider:ethers.Provider
) ⇒string
Retrieves the memo (if present) from a transaction hash by decoding the transaction data.
Generic Utility Functions
safeBigIntToNumber ( value:
bigint
) ⇒number
Safely converts a
BigInt
value to anumber
, ensuring it falls within the safe integer rangetrimNullCharacters ( str:
string
) ⇒string
Removes trailing null characters (
\u0000
) from a string.isValidDate ( timestamp:
any
) ⇒boolean
Validates if the provided Unix timestamp is a date that is today or in the future.
filterEventsByIdentity ( events:
any
, identity:string
) ⇒Array<any>
Function to filter events by Identity
ethereumAddressToDecimal ( address:
string
) ⇒string
Converts an Ethereum address to its decimal representation.
decodeLogsFromReceipt ( receipt:
any
) ⇒Array<any>
Decodes logs from a transaction receipt.
getEventsFromAbi ( abi:
any
) ⇒Array<any>
Retrieves events from an ABI definition.
getEventStruct ( events:
any
) ⇒any
Extracts event structures from ABI events.
replacer ( key:
any
, value:any
) ⇒any
Replaces
bigint
values with their string representation during JSON serialization.fundAccount ( faucetUrl:
string
, address:string
) ⇒any
Funds an account using a specified faucet URL.
generateRandomListingId () ⇒
string
Generates a random listing ID consisting of hexadecimal characters.
generateOfferId ( length?:
number
) ⇒string
Generates a random offer ID of a specified length using hexadecimal characters.
transformDatastore ( dataStore:
string
) ⇒string
Transforms a datastore name to its corresponding collection name.
passRefutationPeriod ( provider:
ethers.JsonRpcProvider
) ⇒void
Passes the refutation period by advancing the blockchain time
getAccountBalance ( address:
string
, provider:ethers.Provider
) ⇒string
Fetch the current balance at an address.
isContract ( address:
string
, provider:ethers.Provider
) ⇒boolean
Determines whether the given address is a contract or an externally owned account (EOA).
isZipFile ( buffer:
Buffer
) ⇒boolean
Checks if the given buffer is a zip file by inspecting its content.
verifySignature ( signature:
string
, message:string | Uint8Array
, expectedAddress:string
) ⇒boolean
Verifies if a given signature matches the expected address by recovering the signer from the message.