How can I execute methods in receive?
receive() external payable{
address _userAddress = msg.sender;
uint256 _amount = msg.value;
weth.deposit{value: msg.value}();
if(_amount>5){
myFoo1(_userAddress, _amount);
}
else{
myFoo2(_userAddress, _amount);
}
}
When I try like that code block, I'm getting this error:
The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance." is error but I have enough balance and as you see function is payable
myFoo1,myFoo2? How are you sending ether to the contract? from an EOA or a contract. Sending from a contract using transfer or send it has a 2300 gas stipend limit. Sending from an EOA should work fine. – Ismael Jul 15 '21 at 05:11