5

Trying to call sendFundsToFriend() method on the testnet contract https://testnet.etherscan.io/address/0xce8efd03766a309af57ddeb9c79f3e7cd23da0df (contract code at https://gist.github.com/anonymous/5bdc3d9032a8b3cb5cba7c7625afa4d7 ) I got:

Warning! Error encountered during contract execution [Out of gas]

The tx result says:

Result: {
  "blockHash": "0x585ca866c5143090c7a82443269d55658a176a018b1ad90827ec70adc1ff66c8",
  "blockNumber": 465927,
  "contractAddress": null,
  "cumulativeGasUsed": 508930,
  "from": "0xe5f68950d479fab12797dabbe5a4b0d88ec7a722",
  "gasUsed": 58787,
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "root": "0x1289d7517d81fa8c4894c0cd97fd200ec4e9f0fecebba586435daca8e4e8f9ec",
  "to": "0xce8efd03766a309af57ddeb9c79f3e7cd23da0df",
  "transactionHash": "0x703d7657c093557d1cd42dfeb7b8d0d3b74e413d22e8009b26d7ac966c85d048",
  "transactionIndex": 3
}
Transaction cost: 58787 gas.

enter image description here

When sending the tx, Transaction gas limit is set to 3000000, the default browser-solidity value.

If tx cost is 58787 gas and the limit is 3000000, why the out of gas error? Any idea? Thx!

P.S.: Tried a similar tx from a geth node instead of using metamask+browser-solidity and it worked ok:

https://testnet.etherscan.io/tx/0x56465b6594769578d9223ca902757780600dd2628074aedcf9635fb590b75bfa

So, I am doing something wrong with browser-solidity when calling the contract method, or might be some kind of bug in this environment...

4
+50

My theory, looking at the transactions of the deployed, is that the failed transactions were to a non-existent address (zero nonce, zero ETH before), and the successful ones were to an existent address (apparently had transactions in the past and ETH already). The former would consume more gas, pushing it beyond the normal gas limit.

The way to test this would be to use metamask+browser-solidity to send to an address that already had ETH. If it fails, then it's not the case. If it doesn't fail, then this is probably what happened.

It may still be a bug in metamask, as it miscalculated how much gas to provide.

EDIT:

I may have found the answer.

Compare a successful geth with an unsuccessful metamask (I presume) shows that the raw transactions are actually different. I suspect whichever client sent the unsuccessful transaction is formatting fields differently, or just buggily.

At this point I'd file a bug with metamask. It's beyond my own ability to debug.

3

At first I thought maybe we were mis-calculating gas somehow and failing transactions, since most of the failed txs have very low gas, but actually sometimes nearly identical transactions seemed to succeed with lower gas, like this pair: https://testnet.etherscan.io/tx/0x5dde4e0536756b380b34a6fed79bda50bbe274c25b07ac1812f0d816917b9fbd https://testnet.etherscan.io/tx/0xd2f0047ee8d6ed27a8435352c809a95484e9c3c0d63a2f672a32dd9a4243e90c

One thing I notice, is that these two are actually different contracts, so I'm not sure which one you posted the source code of.

It's also worth noting that you're using a few patterns for sending that are not recommended in the Solidity docs: https://solidity.readthedocs.io/en/develop/security-considerations.html?highlight=send#sending-and-receiving-ether

I do notice that some of the failed transactions are to contracts, and those are some of the more dangerous times to use the send function, since those contracts could burn up the gas.

Sorry, spent a while on this, not sure I found it.

1

I was facing same issue with Remix + Ganache, I switched to other Ethereum Test Net and issue didnt poped up. Try with some other test-net.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.