There is a mapping in my code as mapping(address => uint) private Payment;. This mapping is used to see who send some ether and how much the sent value is. Its key is an address that stores address of sender and its value is uint that stores the sent value. I need this mapping's records be evaluated in fallback function. So, i write the followed fallback:

function() external payable{

But, whenever i pay some ethers to the contract with Metamask, the transaction will be failed. What should i do?

2 Answers 2


The error is likely that you don't allocate sufficient gas to the transaction. In fact you have to pay for the ETH transfer (21000 gas) + for the storage operation done inside the fallback function.

Therefore try to increase the transaction gas in Metamask options.

Note that the fallback function implementation has been changed in the 0.6 Solidity release (https://solidity.ethereum.org/2020/03/26/fallback-receive-split/).

  • Thank you, It works. I fix payment(address=>bool)... in my post and my Solidity version is 0.5.x.
    – Alireza
    Oct 14, 2020 at 19:24

Because this transaction needs gas more than default value of gas in Metamask. When you write some code in fallback function body, you should pay attention that the fallback function consumes further gas in comparison to the case its body is empty. So, you need to set an appropriate value for gas in Metamask. In Metamask, in process of determine ETH value, there is a field for that. Estimate how much is enough and insert that to the field.

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.