There are multiple methods to withdraw the ETH balance of a contract to the owners' wallet:
function withdrawal() external {
payable(owner).transfer(address(this).balance);
}
function withdrawal() external {
(bool sent,) = payable(owner).call{value: address(this).balance}("");
require(sent, "Failed");
}
I've noticed a lot of articles mentioning that the '.call' version is the recommended one these days.
I do understand that this might be true if sending ETH from one contract to another, due to the fact that a .call is not limited by 2300 gas.
But if the matter of this function is to just send the contract ETH balance to a wallet, where no additional tasks are executed, wouldn't be the .transfer version the better choice? It would automatically limit the gas, as well as reverts on failure, which doesn't require an additional success check...
...or would there be any other reason why .call would be preferred over .transfer in this situation?