Skip to content

Gas Cost

Chain of Industry edited this page Sep 27, 2022 · 4 revisions

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 with a gas limit (gasLimit), which acts as an upper limit of the processing cost.

For all the Send methods provided inside the APIs (SendEGLDTransaction, SendESDTTransaction, SendNFT) the gas cost is automatically computed, no action is needed.

For a Smart contract query or an API call no gas is needed.

For a Smart Contract method call, at the time of the call, the gas for contract execution needs to be provided inside the transaction. Here is the official cost for Smart Contract operation:
View gas cost

To provide the correct gas amount, you can compute the gas cost for each operation from the smart contract which is very hard to do properly.

As Martin proposed on Elrond Developers Telegram group, the best way to determine the cost of a method call is to run your smart contract on Testnet, call the method and see how much gas is required. Then add that gas amount and a little extra as your gas limit.
Determine Gas

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).

The value of the gas limit, does not need to be 100% accurate, it can be a little greater than the gas required for execution.

Clone this wiki locally