I have a payable function that transfers ether to contract.
function test(...) public payable returns (bool) {
...
address(this).transfer(msg.value);
return true;
}
I found that above method fails without having a fallback function in the contract.
function () payable public {}
Can anyone explain this please?
address(this).transfer(msg.value);is redundant anyway, the entire msg.value automatically goes to the contract, you don't have to manually set it. – AnAllergyToAnalogy May 18 '18 at 09:31