Questions tagged [gas]

Gas is a 'sub-currency' which enables the EVM and Ethereum's decentralised computer to run -- with each operation, an amount of gas (proportional to the computational effort required to perform the operation) is consumed.

Gas is required to pay for all operations performed on the blockchain. The Ether used to pay for gas goes to the miner that performs the given computation, in order to reimburse them for the energy used. The price of operations, in gas per opcode, was defined in the yellow paper, in a way that the amount of gas consumed is proportional to the computational effort required to perform the operations.

Gas-related user defined values include:

  • block gas limit: maximum amount of gas to be consumed within a block. Acts as a limit on how many computations can be completed per block. Defined by miners.

  • transaction gas limit: maximum amount of gas allowed to be consumed by a given transaction/operation. Acts as a limit on the amount of computation time an individual contract can use. Defined by user when sending each transaction.

  • gas price: price, in Ether/gas, that a user is willing to pay. Defined by user when sending each transaction.

Requiring users to pay for gas is an anti-DoS mechanism in Ethereum. Otherwise dishonest users could have the miners perform computationally difficult tasks for no benefit to anyone. From the whitepaper:

The intent of the fee system is to require an attacker to pay proportionately for every resource that they consume, including computation, bandwidth and storage; hence, any transaction that leads to the network consuming a greater amount of any of these resources must have a gas fee roughly proportional to the increment.

1704 questions
19
votes
2 answers

Where does the number 21000 come from for the base gas consumption in Ethereum?

Can you break it down in terms of the cost of opcodes?
Hanhan Li
  • 291
  • 2
  • 4
16
votes
3 answers

Is there a max amount of gas per transaction?

If there's an ICO with a cap of $1 million usd and there's $10 million Ether being sent all at the same time, I'm assuming the transaction with the highest gas gets prioritized...but is there a limit to how much gas you can put? For example will…
ello
  • 161
  • 1
  • 1
  • 4
11
votes
2 answers

How to fix: Warning! Error encountered during contract execution [Out of gas]

I have sent ETH to a contract address, and it "failed" the transaction saying it is: Warning! Error encountered during contract execution [Reverted] contract address and transaction failure here:…
goodwin butler
  • 111
  • 1
  • 1
  • 3
7
votes
2 answers

Why gas-used are different for same transfer() tx?

I noticed that the same transfer() calls for a certain ERC20 token cost different gas-used: Gas Used By Txn: 52595 https://etherscan.io/tx/0xa7c1639040725e92d3905cc6b8a4d4a3b21a3e23800c75950da682ce2043c274 Gas Used By Txn:…
7
votes
2 answers

"The contract code couldn't be stored, please check your gas amount." while deploying a simple Faucet contract

I'm trying to deploy the following simple contract to a private Ethereum chain using Geth 1.5.4-stable-b70acf3c: pragma solidity ^0.4.0; contract Faucet { address owner; uint256 sendAmount; function Faucet() { owner =…
Sebastien
  • 323
  • 2
  • 11
6
votes
1 answer

How should an application react when the blockgaslimit is reached?

Because in theory the block gas limit can be reached any time, how would a fully automated contract need to react? How to recognize reliable that it's the block gas limit that rolls back the state change? How to retry the transaction in a secure…
Roland Kofler
  • 11,638
  • 3
  • 44
  • 83
4
votes
0 answers

Insufficient funds in main account (etherbase)main account for gas

I'm using Ethereum/Mist 087. I have 2000 eth in the main account. Trying to send 1800 from the main account to another ether account and Coinbase account. Each time we get the message: Insufficient funds in main account (etherbase) to pay for…
S Seibl
  • 41
  • 1
4
votes
3 answers

Web3j Contract Call Transaction - Always out of gas

Playing around with Web3j, I set up a private, single-node blockchain with Geth using a genesis gas limit of 21 million. I started a node with the following command: geth --datadir ./geth/data --rpc --networkid 611234220438 --nodiscover --mine…
Jodiug
  • 141
  • 1
  • 9
4
votes
1 answer

How much storage is required to store an interface?

Let's say I want to store an interface in EVM storage. Any idea how much this costs and how many slots of storage this takes up? Is it cheaper to store an interface in contract storage or to create a new one every time in…
antioi
  • 61
  • 3
3
votes
1 answer

Does all the gas needed to use EVM go to miners?

I'm trying to understand the financial model of Ethereum and despite all the reading on gas and how transaction cost is calculated still it is ont clear to me whether all gas needed to use EVM goes to miners or it is credited to the organization…
3
votes
1 answer

Can I buy the gas within the contract code?

The contract contains ether. Can I buy the gas within the contract code?
SkyN
  • 175
  • 3
3
votes
1 answer

Same contract spending different amount of gas on its creation

I'm developing a contract and when I try to test it on Remix, sometimes I can create it, sometimes not. creation of ContractName errored: transaction execution failed It seems that the environment requires a huge amount of gas to execute this…
Lucas Yamamoto
  • 185
  • 1
  • 8
3
votes
1 answer

Is it normal for EOA to EOA ether transfer to cost over 21000 gas without data?

In a private testnet, I sent some ether from one external account to another. There is no input data. It cost 24,000 gas, instead of 21,000. Is this normal? >…
sinoTrinity
  • 377
  • 2
  • 8
3
votes
0 answers

contract code couldn't be stored, please check your gas amount

I am trying to deploy multiple dependent contracts with truffle on testrpc. For example,Migration script are as follow: deployer.deploy(a,10000).then(function(instance){ owner = web3.eth.accounts[0]; _a = instance; return…
HARESH
  • 73
  • 6
3
votes
1 answer

What is the maximum size of a Ethereum block in geth (kbs,mbs)?

what is the maximum block size of the Ethereum (need some references ),and can we calculate size with gas if yes please provide any formula,
Mohsin
  • 35
  • 4
1
2 3 4 5 6