[Ethereum] Execution of Fallback function with more 2300 gas

fallback-functiongasgas-limitsolidity

I have tested a contract having a fallback function which updated a state variable (cost 5000 gas). I sent an amount of Ether to this contract with 100000 gas limit. The transaction is valid. As explained in solidity considerations, it should be fail because gas stipend is 2300. Can someone help me explain?

Best Answer

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 to say that there was a 'stipend' of only 2300 gas on such a transaction, but that was mistaken.

The 'stipend' applies to internal sends from one smart contract to another. Because send has no way to specify the gas amount, (whereas call does), Solidity imposes a maximum amount of gas (i.e. 2300).

Because the OP's transaction was not an internal contract-to-contract send the 2300 stipend did not apply and the transaction went through.

Related Topic