0

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{
        Payment[msg.sender]=msg.value;
    }

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

1

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/).

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

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.