Hierarchy

  • BNWrapper<NEAR>
    • NEAR

Constructors

  • Parameters

    • number: string | number | number[] | Uint8Array | Buffer | new BN
    • Optional base: number | "hex"
    • Optional endian: Endianness

    Returns NEAR

  • Parameters

    • number: string | number | number[] | Uint8Array | Buffer | new BN
    • Optional endian: Endianness

    Returns NEAR

Properties

BN: typeof new BN
wordSize: 26

Methods

  • Returns NEAR

    Description

    absolute value

  • Parameters

    Returns NEAR

    Description

    addition

  • Parameters

    • b: number

    Returns NEAR

    Description

    addition

  • Parameters

    Returns NEAR

    Description

    and

  • Parameters

    • b: number

    Returns NEAR

    Description

    and (NOTE: andln is going to be replaced with andn in future)

  • Parameters

    • b: number

    Returns NEAR

    Description

    add 1 << b to the number

  • Returns number

    Description

    get number of bits occupied

  • Returns number

    Description

    return number of bytes occupied

  • Returns NEAR

    Description

    clone number

  • Parameters

    Returns 0 | 1 | -1

    Description

    compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

  • Parameters

    • b: number

    Returns 0 | 1 | -1

    Description

    compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

  • Parameters

    Returns NEAR

    Description

    divide

  • Parameters

    Returns NEAR

    Description

    rounded division

  • Parameters

    • b: number

    Returns NEAR

    Description

    divide

  • Parameters

    Returns {
        a: NEAR;
        b: NEAR;
        gcd: NEAR;
    }

    Description

    Extended GCD results ({ a: ..., b: ..., gcd: ... })

  • Parameters

    Returns boolean

    Description

    a equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a equals b

  • Parameters

    Returns NEAR

  • Parameters

    • width: number

    Returns NEAR

    Description

    convert from two's complement representation, where width is the bit width

  • Parameters

    Returns NEAR

    Description

    GCD

  • Parameters

    Returns boolean

    Description

    a greater than b

  • Parameters

    Returns boolean

    Description

    a greater than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a greater than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a greater than b

  • Returns NEAR

    Description

    absolute value

  • Parameters

    Returns NEAR

    Description

    addition

  • Parameters

    • b: number

    Returns NEAR

    Description

    addition

  • Parameters

    Returns NEAR

    Description

    and

  • Parameters

    • b: number

    Returns NEAR

    Description

    divide

  • Parameters

    • b: number

    Returns NEAR

    Description

    clear bits with indexes higher or equal to b

  • Parameters

    Returns NEAR

    Description

    multiply

  • Parameters

    • b: number

    Returns NEAR

    Description

    multiply

  • Returns NEAR

    Description

    negate sign

  • Parameters

    • w: number

    Returns NEAR

    Description

    not (for the width specified by w)

  • Parameters

    Returns NEAR

    Description

    inverse a modulo b

  • Parameters

    Returns NEAR

    Description

    or

  • Returns boolean

    Description

    check if value is even

  • Returns boolean

    Description

    true if the number is negative

  • Returns boolean

    Description

    check if value is odd

  • Returns boolean

    Description

    check if value is zero

  • Parameters

    • b: number

    Returns NEAR

    Description

    shift left

  • Returns NEAR

    Description

    square

  • Parameters

    Returns NEAR

    Description

    subtraction

  • Parameters

    • b: number

    Returns NEAR

    Description

    subtraction

  • Parameters

    Returns NEAR

    Description

    and

  • Parameters

    Returns NEAR

    Description

    or

  • Parameters

    • b: number

    Returns NEAR

    Description

    shift left

  • Parameters

    • b: number

    Returns NEAR

    Description

    shift right

  • Parameters

    Returns NEAR

    Description

    xor

  • Parameters

    Returns NEAR

    Description

    xor

  • Parameters

    Returns boolean

    Description

    a less than b

  • Parameters

    Returns boolean

    Description

    a less than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a less than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a less than b

  • Parameters

    • b: number

    Returns NEAR

    Description

    test if specified bit is set

  • Parameters

    Returns NEAR

    Description

    returns the maximum of 2 BN instances.

  • Parameters

    Returns NEAR

    Description

    returns the minimum of 2 BN instances.

  • Parameters

    Returns NEAR

    Description

    reduct

  • Parameters

    • b: number

    Returns number

    Deprecated

    Description

    reduct

  • Parameters

    • b: number

    Returns number

    Description

    reduct

  • Parameters

    Returns NEAR

    Description

    multiply

  • Parameters

    • b: number

    Returns NEAR

    Description

    multiply

  • Returns NEAR

    Description

    negate sign

  • Parameters

    • w: number

    Returns NEAR

    Description

    not (for the width specified by w)

  • Parameters

    Returns NEAR

    Description

    or

  • Parameters

    Returns NEAR

    Description

    raise a to the power of b

  • Parameters

    • b: number

    Returns NEAR

    Description

    set specified bit to 1

  • Parameters

    • b: number

    Returns NEAR

    Description

    shift left

  • Parameters

    • b: number

    Returns NEAR

    Description

    shift right

  • Returns NEAR

    Description

    square

  • Parameters

    Returns NEAR

    Description

    subtraction

  • Parameters

    • b: number

    Returns NEAR

    Description

    subtraction

  • Parameters

    • b: number

    Returns boolean

    Description

    test if specified bit is set

  • Parameters

    • Optional endian: Endianness
    • Optional length: number

    Returns number[]

    Description

    convert to byte Array, and optionally zero pad to length, throwing if already exceeding

  • Parameters

    • ArrayType: BufferConstructor
    • Optional endian: Endianness
    • Optional length: number

    Returns Buffer

    Description

    convert to an instance of type, which must behave like an Array

  • Parameters

    • ArrayType: any[]
    • Optional endian: Endianness
    • Optional length: number

    Returns any[]

  • Convert to BigInt type

    Returns bigint

    BigInt

  • Parameters

    • Optional endian: Endianness
    • Optional length: number

    Returns Buffer

    Description

    convert to Node.js Buffer (if available). For compatibility with browserify and similar tools, use this instead: a.toArrayLike(Buffer, endian, length)

  • Convert to string such as "1,000 N", "1 mN", or "1 nN"

    Returns string

    string showing NEAR amount in a human-readable way

  • Returns string

  • Returns number

    Description

    convert to Javascript Number (limited to 53 bits)

  • Parameters

    • reductionContext: ReductionContext

    Returns RedBN

    Description

    Convert number to red

  • Parameters

    • Optional base: number | "hex"
    • Optional length: number

    Returns string

  • Parameters

    • width: number

    Returns NEAR

    Description

    convert to two's complement representation, where width is bit width

  • Parameters

    Returns NEAR

    Description

    and

  • Parameters

    Returns 0 | 1 | -1

    Description

    compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

  • Parameters

    Returns NEAR

    Description

    reduct

  • Parameters

    Returns NEAR

    Description

    or

  • Parameters

    • b: number

    Returns NEAR

    Description

    shift left

  • Parameters

    • b: number

    Returns NEAR

    Description

    shift right

  • Parameters

    Returns NEAR

    Description

    xor

  • Parameters

    Returns NEAR

    Description

    xor

  • Returns number

    Description

    return number of less-significant consequent zero bits (example: 1010000 has 4 zero bits)

  • Converts a BN, number, or string in yoctoNear to NEAR.

    Parameters

    Returns NEAR

    Example

    const nearAmt  = NEAR.from(new BN("10000000"));
    const nearAmt2 = NEAR.from("1");
  • Parameters

    • b: any

    Returns b is new BN

    Description

    returns true if the supplied object is a BN.js instance

  • Parameters

    Returns new BN

    Description

    returns the maximum of 2 BN instances.

  • Parameters

    Returns new BN

    Description

    returns the minimum of 2 BN instances.

  • Parameters

    Returns ReductionContext

    Description

    create a reduction context with the Montgomery trick.

  • Convert human readable NEAR amount string to a NEAR object.

    Parameters

    • x: string

      string representation of NEAR tokens amount

    Returns NEAR

    new NEAR object wrapping the parsed amount

    Example

    NEAR.parse('1')     // => NEAR<'1000000000000000000000000'> (1e24 yoctoNEAR; 1 NEAR)
    NEAR.parse('1,000') // => NEAR<'1000000000000000000000000000'> (1e27 yoctoNEAR; 1,000 NEAR)
    NEAR.parse('1 mN') // => NEAR<'1000000000000000000000'> (1e21 yoctoNEAR; 0.001 NEAR)
    NEAR.parse('1 nN') // => NEAR<'1000000000000000'> (1e15 yoctoNEAR; 0.000000001 NEAR)
  • Parameters

    • reductionContext: IPrimeName | new BN

    Returns ReductionContext

    Description

    create a reduction context

Generated using TypeDoc