46
votes
Accepted
How do I detect a failed transaction after the Byzantium fork as the REVERT opcode does not consume all gas?
Summary
After the Byzantium fork, eth.getTransactionReceipt(...) will return a status field. The status field has a value of 0 when a transaction has failed with the REVERT opcode and 1 when the ...
29
votes
Truffle deployment on test network says: Error: exceeds block gas limit
Inside truffle.js, add
,gas: 4600000
Don't forget the little ","
so it looks like
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*",
gas: ...
25
votes
Accepted
How to clear large arrays without blowing the gas limit?
The best way is simply not to clear them. In many (most?) situations, the array varies in size over time, and emptied slots will eventually be filled again. Instead of shortening the array, keep a ...
23
votes
Accepted
Why does a Solidity throw consume all gas?
All gas is consumed because the EVM essentially only has 1 exception: Out of Gas.
To see this clearer, take a look at the difference between a "pure" exception, and an error due to bad/buggy/invalid ...
eth♦
- 85k
20
votes
Accepted
Does an entire transaction revert when throw occurs?
In Solidity, by default, yes.
On the EVM-level, a throw (bad jump, out-of-gas, or any other exception) only reverts the call it is inside. Solidity helpfully continues the exception down the stack ...
18
votes
Accepted
What happens if transaction runs out of gas before transaction completes?
Correct, it rolls back. Except for one thing: it gives the miner all the gas, you don't get that back. That's what keeps attackers from spamming, and it's fair anyway because the miner still had to do ...
17
votes
Accepted
Error: VM Exception while processing transaction: out of gas
First check your account balance : balance = web3.eth.getBalance(someAddress);
then try to specify the gaslimit contractInstance.createProposal("ADHD", "Foo", 2, {from: web3.eth.accounts[1], gas:...
15
votes
Accepted
How to know if a transaction went through or not? (out of gas)
Using etherscan blockchain explorer
In etherscan, look for the TxReceipt Status which will have Fail in red, or Success in green.
Example of a failure:
https://ropsten.etherscan.io/tx/...
eth♦
- 85k
15
votes
What does a "bad JUMPDEST" error mean?
Malformed instructions are only one cause of bad JUMPDEST errors. The far more likely cause is an exception while calling another contract. When you call another contract in Solidity, it compiles in a ...
15
votes
Does an entire transaction revert when throw occurs?
To complement @Matthew's answer, it depends on how the call is made in Solidity.
If C calls D.foo(), and foo does a throw, then yes the entire transaction is reverted.
If C does a "lower-level raw ...
eth♦
- 85k
13
votes
Accepted
Who gets the fee from contract call?
"Call" is an overloaded term because it is one form of invoking a contract (see What is the difference between a transaction and a call?) and it depends where the invocation is performed, in relation ...
eth♦
- 85k
12
votes
How do I know when I've run out of gas programmatically?
Since block 4370000 (Byzantium) eth.getTransactionReceipt(transactionHash) will return a status field that has a value of 0 when a transaction has failed and 1 when the transaction has succeeded.
...
eth♦
- 85k
12
votes
Accepted
How do I know when I've run out of gas programmatically?
There currently isn't a clear signal that you've run out of gas. A log message is being added to some future release.
Currently what I do is check to see if gasSent == gasUsed. This requires your ...
11
votes
Why does a Solidity throw consume all gas?
In part I believe this was a security decision to ensure spamming the network with bogus transactions cost the sender gas. For instance, if gas was refunded after a throw, a malicious actor could ...
11
votes
Why does a Solidity throw consume all gas?
The Solidity throw instruction gets compiled to an invalid JUMP instruction (i.e. a jump to an invalid location).
The section 9.4.2 of the Yellow Paper explains how exceptional halting works, in ...
10
votes
Accepted
Why is an account not accepting the Ether sent to it?
If you look at the VM trace, you can see that the 100 Finney transactions ran into Out-of-Gas exceptions. In the case of an exception, all value included in the transaction is returned to the sender.
...
10
votes
Out of Gas invoking precompiled contracts on private blockchains
There is a general gas cost rule that states that sending message to
any non-existing account costs more than sending message to an existing account. That also applies to the accounts of the ...
9
votes
Accepted
All cases when Solidity compiles to invalid jump destination
Jumps to invalid jump destinations are generated only for (explicit or implicit) exceptions. An explicit exception is when you use the keyword throw. Implicit exceptions happen for runtime errors:
...
8
votes
Accepted
How come I need to specify a higher gasLimit than estimateGas?
I believe in some cases cumulativeGasUsed is not accurate due to spending gas / refunding gas. If at any point the contract gets above the gasLimit, it will fail with an Out of Gas exception. If a ...
8
votes
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 ...
eth♦
- 85k
8
votes
My transaction failed due to running out of gas. Can I recoup this money?
That transaction had a very high gas price specified (0.000025 Ether, 25,000 GWei), while currently transactions are getting confirmed for much lower (0.000000002 Ether, 2 GWei). And the transaction ...
7
votes
Why does a Solidity throw consume all gas?
The throw instruction is a EVM hack that reverts all changes made by current contract execution. It exploits exceptional termination of EVM which also consumes all gas.
7
votes
Accepted
How to avoid/detect multiple internal transaction out-of-gas side effects?
The entire operation did not revert because enough gas was provided by the transaction origin of the overall transaction. If insufficient gas was provided, then you would observe the behavior you ...
eth♦
- 85k
7
votes
How come I need to specify a higher gasLimit than estimateGas?
You don't.
You can specify the gas exactly and it should go through just fine. The only gotcha is that if the contract state changes that you're executing against, and it would require more gas than ...
7
votes
Accepted
Out of gas problem with transaction
An easier to interpret trace can be seen here at ether.camp.
What happened is that the contract tried to call another contract, specifying a gas quantity of self.gas - 34050. Since your execution had ...
7
votes
Why is my TX failing due to lack of gas even though the correct amount of gas was supplied?
Understanding this puzzle can be instructive.
The behavior can be explained by the way the CALL instruction works in terms of gas.
We can compare the transactions VM traces here:
OK: https://live....
6
votes
Accepted
Specifying gas amount for contract call from JavaScript
Try changing
contracts['CrowdFunder'].contract.contribute({
value: web3.toWei(0.000000000000000005, 'ether')
});
to
contracts['CrowdFunder'].contract.contribute({
value: web3.toWei(0....
6
votes
All cases when Solidity compiles to invalid jump destination
Array Out Of Bounds
contract InvalidJump {
uint[5] data;
function invalidJump1() {
uint i = 6000;
data[i] = 1;
}
}
And the message is from debug.traceTransaction(...) is:
...
6
votes
Accepted
Do nodes by default relay transactions that fail and spend all gas (e.g. Solidity throw)?
Yes, nodes relay the transactions by default. Transactions are relayed before they are executed and their gas consumption and behavior is determined. Nodes just do a basic check such as:
is the ...
eth♦
- 85k
6
votes
Cannot tranfer() ETH to Gnosis Safe
This is explanied here:
https://help.gnosis-safe.io/en/articles/5249851-why-can-t-i-transfer-eth-from-a-contract-into-a-safe
You can also check further information in this post
https://consensys....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
out-of-gas × 264gas × 90
solidity × 78
gas-limit × 55
transactions × 34
contract-development × 23
truffle × 21
gas-estimate × 21
contract-deployment × 20
remix × 18
contract-invocation × 16
web3js × 15
contract-debugging × 15
exceptions × 13
metamask × 12
evm × 11
testrpc × 11
ether × 10
go-ethereum × 9
arrays × 9
gas-price × 8
blockchain × 7
etherscan × 7
truffle-migration × 7
contract-design × 6