@vearnfi/gas
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published

test coverage Maintainability

Vechain Gas Price Calculation

Acknowledgement

This is a fork from the excellent work of vechain.energy Vechain Gas Price Calculation

Basic Usage

npm i @vearnfi/gas
import {calcTxFee} from "@vearnfi/gas";

const clauses = [
  {data: "0x", value: "0x0", to: "0x1A6f69Bb160c199B1862c83291d364836558AE8F"},
];
const txFee = await calcTxFee(clauses);

This will:

  1. calculate the intrinsic gas
  2. load the base price from the network
  3. 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,
};

/@vearnfi/gas/

    Package Sidebar

    Install

    npm i @vearnfi/gas

    Weekly Downloads

    2

    Version

    6.0.0

    License

    MIT

    Unpacked Size

    108 kB

    Total Files

    51

    Last publish

    Collaborators

    • vearnfi