Skip to main content

Module: utils/format

Variables​

NEAR_NOMINATION​

Const NEAR_NOMINATION: BN

Number of indivisible units in one NEAR. Derived from NEAR_NOMINATION_EXP.

Defined in​

utils/format.ts:11


NEAR_NOMINATION_EXP​

Const NEAR_NOMINATION_EXP: 24

Exponent for calculating how many indivisible units are there in one NEAR. See NEAR_NOMINATION.

Defined in​

utils/format.ts:6

Functions​

formatNearAmount​

formatNearAmount(balance, fracDigits?): string

Convert account balance value from internal indivisible units to NEAR. 1 NEAR is defined by NEAR_NOMINATION. Effectively this divides given amount by NEAR_NOMINATION.

Parameters​

NameTypeDefault valueDescription
balancestringundefineddecimal string representing balance in smallest non-divisible NEAR units (as specified by NEAR_NOMINATION)
fracDigitsnumberNEAR_NOMINATION_EXPnumber of fractional digits to preserve in formatted string. Balance is rounded to match given number of digits.

Returns​

string

Value in Ⓝ

Defined in​

utils/format.ts:28


parseNearAmount​

parseNearAmount(amt?): string | null

Convert human readable NEAR amount to internal indivisible units. Effectively this multiplies given amount by NEAR_NOMINATION.

Parameters​

NameTypeDescription
amt?stringdecimal string (potentially fractional) denominated in NEAR.

Returns​

string | null

The parsed yoctoⓃ amount or null if no amount was passed in

Defined in​

utils/format.ts:53