What is gas?

The extra cost necessary to carry out a smart contract or transaction on the blockchain network is referred to as gas in the decentralised U2U network.

Why is this there? There are a few significant restrictions when it comes to using smart contracts:

  1. To ensure the authenticity of every deployed transaction, smart contract, or execution of a smart contract, each entire node on the U2U network must execute it. Although newer blockchains are streamlining this, this is incredibly inefficient.

  2. Smart contracts have the ability to run indefinitely since they are Turing complete, locking up every node on the blockchain.

Gas in U2U network refers to the additional fee required to execute a smart contract or transaction on the blockchain network.

What is Turing completeness?

Given enough time and resources, a programming language that is Turing complete can, in theory, solve or represent any computational issue, regardless of how difficult it may be. That specifically has the following implications:

  1. Though the implementation might be excessively time-consuming, every Turing complete language can theoretically be used to describe the logic of another Turing complete language.

  2. Turing-complete programmes are capable of looping endlessly. In truth, there is no way to conclusively demonstrate that such a programme won't end up running indefinitely (the "halting problem").

For example, a regular calculator is not Turing complete, because it allows for only a few types of calculations. However, a computer or scientific calculator is Turing complete because any type of program can be executed on it.

Since smart contract programs can run forever, gas has become the practical way in U2U network to manage the impact of a blockchain program! Every computation or transaction made on the blockchain costs some fees. These fees prevent expensive (or endless) contract executions, ensure miners are fairly compensated for the work they do, and provide a fair market to prioritize which transactions make it onto the blockchain.

Calculating Gas Costs

For any given program, the total gas used is calculated as the sum of the gas for each operation executed by the Ostracism Virtual Machine (EVM-compatible). For example, adding two numbers in a smart contract costs 3 gas, whereas sending a transaction costs 21,000 gas.

The total cost of gas is found by taking the amount of gas used in by a smart contract and multiplying by the gas price, a value set by you, the transaction sender.

Setting a higher gas price for your transaction means it's more likely to be confirmed on the blockchain. However, it also costs more U2U for the sender.

Another important value that can be set is the gas limit, or the maximum amount of gas you're willing to spend on your transaction.

By multiplying the gas price by the gas limit, you'll get the maximum amount of Ether you're allowing Ethereum to spend on gas fees for any particular transaction.

What is "gwei" or "wei", and how do they relate to U2U?

“Wei” is the smallest unit of U2U, where 10¹⁸ Wei represents 1 U2U. One gwei is 10⁹ wei, and there are 10⁹ gwei per U2U.

Learn about gas execution

When a smart contract call is made, the call (or transaction) will attempt to use the gas provided while the program is executed.

  • If the call succeeds, the unused gas will be returned to the sender.

  • If the call fails because it ran out of gas, the entire transaction will revert, undoing all changes to the blockchain. None of the gas will be returned, since it will all have been used up during the computation process.

Last updated