Skip to content
This repository has been archived by the owner on Mar 18, 2020. It is now read-only.

Latest commit

 

History

History
216 lines (124 loc) · 5.11 KB

index.md

File metadata and controls

216 lines (124 loc) · 5.11 KB

Table of Contents

TxGasUtil

index.js:23-153

tx-gas-utils are gas utility methods for Transaction manager its passed ethquery and used to do things like calculate gas of a tx.

Parameters

  • provider Object A network provider.

analyzeGasUsage

index.js:33-54

Parameters

  • txMeta {Object} - the txMeta object
  • getCodeResponse

Returns object the txMeta object with the gas written to the txParams

estimateTxGas

index.js:62-108

Estimates the tx's gas usage

Parameters

  • txMeta {Object} - the txMeta object
  • blockGasLimitHex {string} - hex string of the block's gas limit
  • getCodeResponse

Returns string the estimated gas limit as a hex string

setTxGas

index.js:116-131

Writes the gas on the txParams in the txMeta

Parameters

  • txMeta {Object} - the txMeta object to write to
  • blockGasLimitHex {string} - the block gas limit hex
  • estimatedGasHex {string} - the estimated gas hex

addGasBuffer

index.js:140-152

Adds a gas buffer with out exceeding the block gas limit

Parameters

  • initialGasLimitHex {string} - the initial gas limit to add the buffer too
  • blockGasLimitHex {string} - the block gas limit

Returns string the buffered gas limit as a hex string

bnToHex

util.js:11-13

Converts a BN object to a hex string with a '0x' prefix

Parameters

  • inputBn BN The BN to convert to a hex string

Returns string A '0x' prefixed hex string

hexToBn

util.js:22-24

Converts a hex string to a BN object

Parameters

  • inputHex string A number represented as a hex string

Returns Object A BN object

BnMultiplyByFraction

util.js:35-39

Used to multiply a BN by a fraction

Parameters

  • targetBN BN The number to multiply by a fraction
  • numerator (number | string) The numerator of the fraction multiplier
  • denominator (number | string) The denominator of the fraction multiplier

Returns BN The product of the multiplication

addHexPrefix

util.js:47-51

adds a hex prefix does not change the original string

Parameters

Returns string hex value with 0x in the beginning

stripHexPrefix

util.js:59-63

removes hex prefix does not change the original string

Parameters

Returns string hex value with 0x removed from the beginning