Is there some way of receiving Eth in a contract from EOAs (say from most of the existing wallets) and carry out actions as a result?

I know the basic way of receiving Eth is via the receive function. But as per the Solidity documentation

In the worst case, the receive function can only rely on 2300 gas being available (for example when send or transfer is used), leaving little room to perform other operations except basic logging.

So no code (other than an event emit) can be executed without the transaction running out of gas.

Is there some other standard function call that (most/all) existing Wallets call to transfer Eth to a contract? Maybe some standard we haven't come across in learning about all this stuff?

Obviously the contract could implement a payable function, but existing Wallets would not implement any calls to that.

1 Answer 1


You've misunderstood the limitation a bit.

The limitation of 2300 gas depends on how the function is being called. There's a Solidity function called transfer than can be used for transferring Eth from a smart contract to another address. Using that function only forwards 2300 gas.

But if you're expecting the receive Eth from EOAs there are no such gas restrictions. If your function requires a million gas to run, then that estimate is given when whoever sends the Eth and they can decide whether to send the transaction or not.

Even if the assets were coming from another smart contract, there are other ways to send more gas along with the call. transfer is just one of the options.

  • According to solidity-by-example.org/sending-ether there is a gas limit of 2300 on the transfer function. Maybe I've not been clear enough with the question. We know we can write a payable function that can receive Eth and carry out various gas-using operations, but a wallet would need to know that function to call it. But is there any standard function that existing wallets already call to send Eth to a contract that they don't know and that function can carry out gas-using operations?
    – ThomasS
    Commented Mar 15 at 13:29
  • So, if we deploy a contract and provide that contract's address to an arbitrary wallet holder, how would that wallet holder send Eth to that contract address and, on receiving the Eth, that contract would carry out some operations that use gas?
    – ThomasS
    Commented Mar 15 at 13:33
  • You've said it yourself already: use the payable receive function. It gets triggered if no other function is called. And sending Eth from an EOA does not use the transfer function, and therefore there is no gas limit. If your function requires a million gas, the wallets see this and tell the user that this execution will cost a million gas. Commented Mar 16 at 14:00
  • You're correct - in our testing using the receive function the transfer was failing, but it turns out we just weren't sending enough gas to cover the operations. We incorporated the gas and fee estimation calls to get the expected amounts and now we can send Eth to the receive function and carry out operations in there. Thanks.
    – ThomasS
    Commented Mar 17 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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