# Tag Info

## Hot answers tagged gas-limit

Accepted

### how to estimate gas cost?

Using Truffle and testrpc. It's actually pretty easy to build a development environment and test different use cases. For the gas estimation, it's mostly based on Web3 native functions: You can ...
• 7,247
Accepted

### Are gas limit in transaction and block gas limit different?

Yes. Each transaction has a gas limit. For example, there could be 5 unmined transactions where each has a gas limit of 10, 20, 30, 40, 50. The block gas limit determines how many transactions can ...
• 86.2k

### Execution of Fallback function with more 2300 gas

I was confused by this questions and self answer, so I will try to clarify. The OP sent 1,000,000 gas to a smart contract from an external account. He/she incorrectly read the Solidity documentation ...
• 9,963

### Is there a limit for transaction size?

As of 12/08/2017, the gas limit as detailed on EthStats.net is 6,700,314. The gas limit was 'stuck' at 4.7 million. It was recommended that miners change their settings such that the gas limit could ...
• 4,385

### Does Gas Limit have any bearing on transaction/mining time?

Yes, a transaction's gas limit can have an effect on the time it takes to get mined into a block. Larger gas limits can be more enticing to miners since their potential fee is gas limit * gas price. ...
• 86.2k
Accepted

### How do you calculate gas limit for transaction with data in Ethereum?

According to Ethereum Yellow Paper, in order to calculate gas limit for transaction with non-zero data you will need to use the following formula: gasLimit = Gtransaction + Gtxdatanonzero × ...
Accepted

### How do I get `gasLimit` in web3?

Asking for the last block mined, it will return the gasLimit of the block https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgetblock var block = web3.eth.getBlock("latest"); ...
• 176
Accepted

### Gas consumption of a view public function

You don't pay gas when calling a view function. This doesn't change the fact it still has operations to do, which have costs, and thus are subject to the upper-bound gas limit on the block, as well as ...
• 2,641

### If view or pure function doesn't cost any gas, would they be abused/free ride?

pure and view functions only are "free" when you call them externally, as in you call that function by itself and run the calculation on your node. So if you had a function that returned "1+1", yes ...
• 8,068
Accepted

### Error: "The contract code couldn't be stored, please check your gas limit"

How did you get the bytecode? Does it have the '0x' at the beginning? Can you try adding the '0x' when submitting the transaction? .deploy({ data: '0x' + bytecode, arguments: ['Hi there!'] }) If ...
• 30.4k
Accepted

### If view or pure function doesn't cost any gas, would they be abused/free ride?

Just to add to @Shawn's good answer. Yes, you can abuse them. But as the pure and view computations are performed only on your own node you would only hurt your own node. You would not hurt the ...
• 29.7k
Accepted

### How to increase gas limit in block using geth?

While it's advised to not alter a chain's gas limit once created, it may become necessary to fiddle with the gas limit of an existing private blockchain, especially during development. On geth, this ...

### how to estimate gas cost?

The answer provided by Greg Jeanmart perfectly explained how to estimate the gas cost for a function. Here I want to point out that the design of your function giveAwayDividend() might be vulnerable ...
• 146
Accepted

### Solidity Exceeds block gas limit during Mocha Tests with Ganache-cli

The error message "n: Exceeds block gas limit" means your transaction has declared a gas value greater that the maximum allowed in the network. A client will reject such transaction. With ganache-...
• 30.4k
Accepted

### Does using a very high gas limit somehow get your transactions executed slower?

In short: It's exactly as you suspect, a higher gas limit means your transaction is less likely to be included by miners. The reasoning: miners seek to maximize their profit within each block. Calls ...
• 2,876
Accepted

### What happens when I send a transaction that exceeds the gas limit of 3,141,592?

The target block gas limit was PI million, but was increased to 1.5 PI million (4,712,388) in Homestead. If you exceed the limit, in Geth, you will get error "Exceeds block gas limit" and the ...
• 86.2k
Accepted

### How Geth and Parity knows the global gas limit?

The block gasLimit is in each block. Example: eth.getBlock(1500000) { difficulty: 34982465665323, extraData: "0xd783010305844765746887676f312e352e31856c696e7578", gasLimit: 4712388, ... }
• 86.2k

### How to increase gas limit in block using geth?

Short answer Can't or shouldn't. Better answer The block gaslimit is a property of the network. If you're using a private chain you can fiddle with it in the genesis block. On a real blockchain, ...
• 55.4k

### Gas limit of a contract method call

When an externally owned account (EOA) signs a transaction, their client will usually estimate the gas requirement and provide enough to make it work. This doesn't always work out as expected. ...
• 55.4k
Accepted

### Is there a gas limit for view requests?

If you are calling this from an external account (using web3 or similar) then there is no gas cost associated because the function is view and is resolved in the node you are connected to. On the ...
• 8,360
Accepted

### Is there a drawback of setting a too high gas limit for a transaction?

If the transaction executes your on-chain function, which you obviously have 100% confidence of for not spending an excessive amount of gas, then the only drawback is that the gas limit that you set ...
• 26.1k
Accepted

### Private chain: Maximum size of "data" field in an Ethereum transaction?

In genesis.json you can set the block gas limit and then see How can I stop the block gas limit on a private chain dropping to the public chain default? Does it mean that I can transfer any amount ...
• 86.2k
Accepted

### For higher priority would it be a good idea to send a transaction with highest gasPrice?

Don't confuse gas value with gasprice. web3.eth.sendTransaction({/* ... */,gas: 99570000 , gasPrice: 12345}); Miners will Prioritize the transactions with a higher gas price not a gas value (how ...
• 18.8k
Accepted

### What is the relationship between Gwei and gas?

Gas is needed by miners to execute a transaction. The more complicated a transaction is, the more gas they will need. When you send a transaction, you (or your wallet program) has to configure two ...
• 10.5k
Accepted

### Truffle - test - how to get more than 10 accounts?

Truffle tests run ganache-cli behind the scene in default mode (10 accounts). But if you run yourself ganache-cli with x accounts generated, you will have access to all of these accounts from your ...
• 7,247

### Gas for view functions

View will not cost gas only if called from outside the network, that is if a function in a contract is view and is called from another contract it will cost gas. The reason it will not cost gas if ...
• 8,360

### Truffle and Ganache - do I need to set the same gas-price and gas-limit in both of them?

TL;DR: Yes you can use the same value. Here is why: Ganache Ganache is a local test Blockchain. -l or --gasLimit is the block gas limit (total amount in gas unit that can fit in a block). Let's ...
• 7,247
Accepted

### How to call Library Function from a Contract? => [error] The contract code couldn't be stored, please check your gas amount. undefined

From Library contract method failing #2831: You probably run geth with the --dev option to create a private network? In that case use the init subcommand to create a private chain. Instructions can ...
• 40.3k
Accepted

### Is it possible that the block gas limit will drop below its current level?

Here are the current values for Geth: MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be. GenesisGasLimit = big.NewInt(4712388) // Gas limit of the ...
• 86.2k