So for example, we have the following contract:
contract testThrowContract {
function testThrow() {
throw;
}
}
Once the contract is compiled and mined run the following:
testThrowContract.testThrow({from:eth.accounts[0]});
As the only statement executed is the “throw” and no fuel is used; then why does a transaction in the block get created as no state has changed? I wouldn’t have expected a transaction to be written to the chain in this particular case.
I have included the transaction details in the block below, which shows the zero fuel zero ether transaction.
247545741fb873756b4e78229cd13ea7c84f42d0 – account 0 address
582db222db4de8dcee5a8290ec6df5ba7a2ccf10 – contract address
Block(#429): Size: 625.00 B {
MinerHash: bd40b8144802aeb26ff3a1956490be0d656540a6226f80b73d2d11cf7315c2b9
Header(8f1bc57bd58a9a6bc880d752f15f5e5c4e77b301cce1edbeeeab983bea7c5f48):
[
ParentHash: bf58b219fa66f594cca8a2b735b151d108544cfcfaa57426281cf0c53de0b4c8
UncleHash: 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347
Coinbase: f75c1904a0eef5b3ebfa5ad47873d6cecdef25ba
Root: a939bfe8447ac888193b89d4794715d05373fa565b89593de9bf966072835530
TxSha c034514f6fa18ba0fdba91687a361c743326f58580012baebba8158aa0e1c281
ReceiptSha: 1de7eeaf04e4de6448f2f72cd72b970bfcb543d93e6bba21e0a5cee56b7dd59c
Bloom: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Difficulty: 131072
Number: 429
GasLimit: 2824425312
GasUsed: 90000
Time: 1459847668
Extra:
MixDigest: 07a0273d89b81897efc7364a12e36ba2e455289f9d89bd3bbdf50c62fcdc0941
Nonce: 49cee41f1edfe616
]
Transactions:
[
TX(1d94bdfa6f4fcfea153a09d9dd73db97c8fca3646ccced9b68a04200862d8c5a)
Contract: false
From: 247545741fb873756b4e78229cd13ea7c84f42d0
To: 582db222db4de8dcee5a8290ec6df5ba7a2ccf10
Nonce: 109
GasPrice: 20000000000
GasLimit 90000
Value: 0
Data: 0x50bff6bf
V: 0x1c
R: 0x8e56dbc903cd35bdf57596882276fd19d1eb4831548f980adc14e9d565ad4d4b
S: 0x6724d3804ddea85ac43d112638217aa8e41ef192664cf5a7ebc19b4567c8a392
Hex: f8696d8504a817c80083015f9094582db222db4de8dcee5a8290ec6df5ba7a2ccf10808450bff6bf1ca08e56dbc903cd35bdf57596882276fd19d1eb4831548f980adc14e9d565ad4d4ba06724d3804ddea85ac43d112638217aa8e41ef192664cf5a7ebc19b4567c8a392
]
Uncles:
[]
}
0 ·
Comments
My guess is that when the transaction is created it's not easy to determine if the statement consumes gas so results in a no-op transaction. So the miners will pick it up but they don't get paid for it.
Also I don't think all the gas gets consumed on a throw as that doesn't seem to make sense but I need to test that out.