Transaction Fees

Indications how TX fees can be retrieved or calculated for the web3.js compatible blockchains as well as Substrate compatible chains and Elrond.

W.I.P.

Elrond Gas Fees

Web3.js compatible:

Ropsten (Ethereum), BSC Gas Fees, HECO Transaction Fees

var sender = web3.eth.accounts[0];
var receiver = web3.eth.accounts[1];
var balance = web3.eth.getBalance(sender);
var gasPrice = web3.eth.getGasPrice(); // estimate the gas price

var transactionObject = {
  from: sender,
  to: receiver,
  gasPrice: gasPrice,
}

var gasLimit = web3.eth.estimateGas(transactionObject); // estimate the gas limit for this transaction
var transactionFee = gasPrice * gasLimit; // calculate the transaction fee

transactionObject.gas = gasLimit;
transactionObject.value = balance - transactionFee; // set the transaction value to the entire balance, less the transaction fee

web3.eth.sendTransaction(transactionObject, myCallbackFunction);

XP.network Transaction Fees

Since XP.network uses the Substrate Parachain framework for its nodes we can use the inherent Polkadot transaction fee as a foundation as described in the documentation below.

  1. The fees are deducted from a common account for signed transactions prior to the transaction execution.

  2. The fee consists of two obligatory and one optional part:

    1. The length fee (per-byte fee)

      It is a product of the multiplication of a product-per-byte and the number of bytes.

    2. The weight fee

      Each TX has a base weight

    3. Tips (optional)

      Tips allow to give a transaction higher priority and increase the probability of inclusion in the block.

    4. The transaction fee is split into the following parts:

      1. 20% go to the block producer

      2. 80% go to the Treasury

The Transaction payment pallet is responsible for withdrawing, refunding & calculating the TX fees.

Last updated

Was this helpful?