Hierarchy

  • BNWrapper<Gas>
    • Gas

Constructors

  • Parameters

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

    Returns Gas

  • Parameters

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

    Returns Gas

Properties

BN: typeof new BN
wordSize: 26

Methods

  • Returns Gas

    Description

    absolute value

  • Parameters

    Returns Gas

    Description

    addition

  • Parameters

    • b: number

    Returns Gas

    Description

    addition

  • Parameters

    Returns Gas

    Description

    and

  • Parameters

    • b: number

    Returns Gas

    Description

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

  • Parameters

    • b: number

    Returns Gas

    Description

    add 1 << b to the number

  • Returns number

    Description

    get number of bits occupied

  • Returns number

    Description

    return number of bytes occupied

  • Returns Gas

    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 Gas

    Description

    divide

  • Parameters

    Returns Gas

    Description

    rounded division

  • Parameters

    • b: number

    Returns Gas

    Description

    divide

  • Parameters

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

    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 Gas

  • Parameters

    • width: number

    Returns Gas

    Description

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

  • Parameters

    Returns Gas

    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 Gas

    Description

    absolute value

  • Parameters

    Returns Gas

    Description

    addition

  • Parameters

    • b: number

    Returns Gas

    Description

    addition

  • Parameters

    Returns Gas

    Description

    and

  • Parameters

    • b: number

    Returns Gas

    Description

    divide

  • Parameters

    • b: number

    Returns Gas

    Description

    clear bits with indexes higher or equal to b

  • Parameters

    Returns Gas

    Description

    multiply

  • Parameters

    • b: number

    Returns Gas

    Description

    multiply

  • Returns Gas

    Description

    negate sign

  • Parameters

    • w: number

    Returns Gas

    Description

    not (for the width specified by w)

  • Parameters

    Returns Gas

    Description

    inverse a modulo b

  • Parameters

    Returns Gas

    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 Gas

    Description

    shift left

  • Returns Gas

    Description

    square

  • Parameters

    Returns Gas

    Description

    subtraction

  • Parameters

    • b: number

    Returns Gas

    Description

    subtraction

  • Parameters

    Returns Gas

    Description

    and

  • Parameters

    Returns Gas

    Description

    or

  • Parameters

    • b: number

    Returns Gas

    Description

    shift left

  • Parameters

    • b: number

    Returns Gas

    Description

    shift right

  • Parameters

    Returns Gas

    Description

    xor

  • Parameters

    Returns Gas

    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 Gas

    Description

    test if specified bit is set

  • Parameters

    Returns Gas

    Description

    returns the maximum of 2 BN instances.

  • Parameters

    Returns Gas

    Description

    returns the minimum of 2 BN instances.

  • Parameters

    Returns Gas

    Description

    reduct

  • Parameters

    • b: number

    Returns number

    Deprecated

    Description

    reduct

  • Parameters

    • b: number

    Returns number

    Description

    reduct

  • Parameters

    Returns Gas

    Description

    multiply

  • Parameters

    • b: number

    Returns Gas

    Description

    multiply

  • Returns Gas

    Description

    negate sign

  • Parameters

    • w: number

    Returns Gas

    Description

    not (for the width specified by w)

  • Parameters

    Returns Gas

    Description

    or

  • Parameters

    Returns Gas

    Description

    raise a to the power of b

  • Parameters

    • b: number

    Returns Gas

    Description

    set specified bit to 1

  • Parameters

    • b: number

    Returns Gas

    Description

    shift left

  • Parameters

    • b: number

    Returns Gas

    Description

    shift right

  • Returns Gas

    Description

    square

  • Parameters

    Returns Gas

    Description

    subtraction

  • Parameters

    • b: number

    Returns Gas

    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 "53 Tgas" or "900 Ggas"

    Returns string

    string showing gas 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 Gas

    Description

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

  • Parameters

    Returns Gas

    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 Gas

    Description

    reduct

  • Parameters

    Returns Gas

    Description

    or

  • Parameters

    • b: number

    Returns Gas

    Description

    shift left

  • Parameters

    • b: number

    Returns Gas

    Description

    shift right

  • Parameters

    Returns Gas

    Description

    xor

  • Parameters

    Returns Gas

    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 gas units to Gas.

    Parameters

    Returns Gas

    Example

    const gas  = Gas.from(new BN("10000000"))
    const gas2 = Gas.from('1 TGas')
  • 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 gas amount to internal indivisible units.

    Parameters

    • x: string

      decimal string denominated in gas, Tgas, Ggas, etc.

    Returns Gas

    new Gas object wrapping the parsed amount

    Example

    Gas.parse('1') // => Gas<'1'> (1 gas)
    Gas.parse('1 Tgas') // => Gas<'1000000000000'> (1e12 gas)
    Gas.parse('1 Ggas') // => Gas<'1000000000'> (1e9 gas)
  • Parameters

    • reductionContext: IPrimeName | new BN

    Returns ReductionContext

    Description

    create a reduction context

Generated using TypeDoc