@rarcifa/cronos-evm-client
Version:
A Node.js client library for interacting with the Cronos EVM, facilitating operations on both CRC20 and CRC721 tokens.
41 lines (40 loc) • 1.79 kB
TypeScript
/**
* Provides utility functions for formatting and converting blockchain-related data types.
*
* @fileoverview This file includes functions for converting and decoding data types.
* @namespace format
*/
export declare const format: {
/**
* Converts a value from Wei to Ether. Handles various input formats and ensures accurate conversion using floating-point precision.
*
* @param {string | number | bigint | boolean} weiValue - The value in Wei to be converted to Ether.
* @returns {string} The value in Ether, formatted as a string with up to 18 decimal places.
*
* @example
* const etherValue = format.weiToEther("0x3ca751a12dd1da952");
*
*/
weiToEther: (weiValue: string | number | bigint | boolean) => string;
/**
* Decodes a hex string to a readable ASCII string. This function assumes the hex string is ABI-encoded.
*
* @param {string} hexString - The hex string to decode, typically ABI-encoded.
* @returns {string} The decoded ASCII string.
*
* @example
* const asciiString = format.decodeHexString("0x000000......000000000");
*/
decodeHexString: (hexString: string) => string;
/**
* Converts token amounts from the smallest unit based on specified decimals to a formatted string.
*
* @param {string | number | bigint} tokenAmount - The token amount in the smallest unit.
* @param {number} decimals - The number of decimals the token uses.
* @returns {string} The formatted token amount.
*
* @example
* const formattedAmount = format.formatTokenAmount("87824964111949", 6); // Convert smallest token unit to a human-readable format
*/
formatTokenAmount: (tokenAmount: string | number | bigint, decimals: number) => string;
};