Docs

Docs

  • Develop
  • Validate
  • Integrate
  • Learn

›Gas and Fees

Welcome to Elrond

  • Welcome to Elrond

Technology

  • Architecture Overview
  • Glossary
  • Entities
  • Chronology
  • Secure Proof of Stake
  • Adaptive State Sharding
  • The Elrond WASM VM
  • Cross Shard Transactions

Wallet

  • Wallets - Overview
  • Web Wallet
  • Maiar Web Wallet Extension
  • Webhooks
  • Ledger

Tokens

  • Native Tokens
  • ESDT tokens
  • NFT tokens

Validators

  • Validators - Overview
  • System Requirements
  • Install a Mainnet Node

    • Scripts & User config
    • Installing a Validator Node
    • Optional Configurations
    • How to use the Docker Image

    Install a Testnet/Devnet Node

    • Scripts & User config
    • Installing a Validator Node
    • Manage a validator node
    • How to use the Docker Image

    Manage your keys

    • Validator Keys
    • Wallet Keys
    • Protecting your keys

    Staking, Unstaking, Unjailing

    • Staking, unstaking and unjailing
    • Staking
    • Unjailing
    • The Staking Smart Contract
  • The Delegation Manager
  • Convert An Existing Validator Into A Staking Pool
  • Merging A Validator Into An Existing Delegation Smart Contract
  • Rating
  • Elrond Node upgrades
  • Node redundancy
  • Import DB
  • Node CLI
  • Node Databases
  • Useful Links & Tools
  • FAQs

Developers

  • Developers - Overview
  • Tutorials

    • Build a dApp in 15 minutes
    • Build a Microservice for your dApp
    • The Crowdfunding Smart Contract (part 1)
    • The Crowdfunding Smart Contract (part 2)
    • The Counter Smart Contract
    • Custom Wallet Connect

    Signing Transactions

    • Signing Transactions
    • Tools for signing
    • Signing programmatically

    Gas and Fees

    • Overview
    • EGLD transfers (move balance transactions)
    • System Smart Contracts
    • User-defined Smart Contracts

    Developer reference

    • The Elrond Serialization Format
    • Smart contract annotations
    • Smart contract modules
    • Smart contract to smart contract calls
    • Smart Contract Developer Best Practices
    • Code Metadata
    • Smart Contract API Functions
    • Storage Mappers
    • Rust Testing Framework
    • Rust Testing Framework Functions Reference
    • Rust Smart Contract Debugging
    • Random Numbers in Smart Contracts

    Developers Best Practices

    • Basics
    • BigUint Operations
    • The dynamic allocation problem
    • Multi-values

    Mandos tests reference

    • Mandos Overview
    • Mandos Structure
    • Mandos Simple Values
    • Mandos Complex Values
    • Embedding Mandos code in Go
  • Constants
  • Built-In Functions
  • Account storage
  • Setup a Local Testnet
  • Set up a Local Testnet (advanced)
  • Creating Wallets

SDK and Tools

  • SDKs and Tools - Overview
  • REST API

    • REST API overview
    • api.elrond.com
    • Gateway overview
    • Addresses
    • Transactions
    • Network
    • Nodes
    • Blocks
    • Virtual Machine
    • Versions and Changelog
  • Proxy
  • Elasticsearch
  • erdpy

    • erdpy
    • Installing erdpy
    • Configuring erdpy
    • erdpy CLI
    • Deriving the Wallet PEM file
    • Sending bulk transactions
    • Writing and running erdpy scripts
    • Smart contract interactions

    erdjs

    • erdjs
    • Cookbook
    • Extending erdjs
    • Writing and testing interactions
    • Migration guides
    • Signing Providers for dApps
  • erdgo
  • erdcpp
  • erdjava
  • erdkotlin
  • erdwalletjs-cli

Integrators

  • Integrators - Overview
  • EGLD integration guide
  • ESDT tokens integration guide
  • Observing Squad
  • Accounts Management
  • Creating Transactions
  • Querying the Blockchain

Overview

Cost of processing (gas units)

Each Elrond transaction has a processing cost, expressed as an amount of gas units. At broadcast time, each transaction must be provided a gas limit (gasLimit), which acts as an upper limit of the processing cost.

Constraints

For any transaction, the gasLimit must be greater or equal to erd_min_gas_limit but smaller or equal to erd_max_gas_per_transaction, these two being parameters of the Network:

networkConfig.erd_min_gas_limit <= tx.gasLimit <= networkConfig.erd_max_gas_per_transaction

Cost components

The actual gas consumption - also known as used gas - is the consumed amount from the provided gas limit - the amount of gas units actually required by the Network in order to process the transaction. The unconsumed amount is called remaining gas.

At processing time, the Network breaks the used gas down into two components:

  • gas used by value movement and data handling
  • gas used by contract execution (for executing System or User-Defined Smart Contract)
note

Simple transfers of value (EGLD transfers) only require the value movement and data handling component of the gas usage (that is, no execution gas), while Smart Contract calls require both components of the gas consumption. This includes ESDT and NFT transfers as well, because they are in fact calls to a System Smart Contract.

The value movement and data handling cost component is easily computable, using on the following formula:

tx.gasLimit = 
    networkConfig.erd_min_gas_limit + 
    networkConfig.erd_gas_per_data_byte * lengthOf(tx.data)

The contract execution cost component is easily computable for System Smart Contract calls (based on formulas specific to each contract), but harder to determine a priori for user-defined Smart Contracts. This is where simulations and estimations are employed.

Processing fee (EGLD)

The processing fee, measured in EGLD, is computed with respect to the actual gas cost - broken down into its components - and the gas price per gas unit, which differs between the components.

The gas price per gas unit for the value movement and data handling must be specified by the transaction, and it must be equal or greater than a Network parameter called erd_min_gas_price.

While the price of a gas unit for the value movement and data handling component equals the gas price provided in the transaction, the price of a gas unit for the contract execution component is computed with respect to another Network parameter called erd_gas_price_modifier:

value_movement_and_data_handling_price_per_unit = tx.GasPrice
contract_execution_price_per_unit = tx.GasPrice * networkConfig.erd_gas_price_modifier
note

Generally speaking, the price of a gas unit for contract execution is lower than the price of a gas unit for value movement and data handling, due to the gas price modifier for contracts (erd_gas_price_modifier).

The processing fee formula looks like this:

processing_fee = 
    value_movement_and_data_handling_cost * value_movement_and_data_handling_price_per_unit + 
    contract_execution_cost * contract_execution_price_per_unit

After processing the transaction, the Network will send a value called gas refund back to the sender of the transaction, computed with respect to the unconsumed (component of the) gas, if applicable (if the paid fee is higher than the necessary fee).

← Signing programmaticallyEGLD transfers (move balance transactions) →
  • Cost of processing (gas units)
    • Constraints
    • Cost components
  • Processing fee (EGLD)
Made withby the Elrond team.
GithubChat
Main siteWalletExplorerBridgeDocsGrowthMaiarMaiar Exchange