@vechain.energy/gas
v1.0.4
Published
calculate estimated gas usage for transactions
Downloads
83
Readme
Vechain Gas Price Calculation
Basic Usage
yarn add @vechain.energy/gas
import estimate from '@vechain.energy/gas'
const clauses = [{ data: '0x', value: '0x0', to: '0x1A6f69Bb160c199B1862c83291d364836558AE8F' }]
const gasEstimate = await estimate (clauses)
This will:
- calculate the intrinsic gas
- load the base price from the network
- send the clause for vm gas estimation to the network
It will apply the gas calculation with a default gas coef of 0 based on https://docs.vechain.org/thor/learn/transaction-calculation.html
Options are:
type Options = {
nodeOrConnex?: Connex | string // the network to load additional gas information from
caller?: string // optional caller address for the vm gas estimation
gasPriceCoef?: number // priority, 0 (low) to 255 (high)}
which default to:
const defaultOptions = {
nodeOrConnex: "https://mainnet.veblocks.net",
gasPriceCoef: 0,
}