Environment
Truffle v5.1.43
Solidity 0.5.7
Details
Hello everyone! I am trying to withdraw weth on Kovan to get some Ether on my upgradeable proxy contract but the transaction runs out of gas every single time. It fails on the following line on the weth contract:
msg.sender.transfer(wad);
I am aware that sending some ether to a contract will run out of gas if there is no payable fallback function. So I added that function to my contract but no luck.
I have verified I can send Ether to my proxy instance from an EOA and that works. I must be missing something simple here but I can’t find the problem, any help would be great!
Code to reproduce
Here is a simple test proxy contract to reproduce my issue:
pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;
interface IWETH {
function deposit()
external
payable;
function withdraw(
uint256 wad
)
external;
}
contract WethTest {
function() external payable { }
function getWrappedEthInstance() public view returns (IWETH) {
return IWETH(0x8a18c7034aCEfD1748199a58683Ee5F22e2d4e45);
}
function unwrapEtherAndWithdraw(address payable _to, uint256 _withdrawalAmount)
external
{
this.getWrappedEthInstance().withdraw(_withdrawalAmount);
_to.transfer(_withdrawalAmount);
}
}
And here is a tenderly link for a transaction that failed, you can clearly see the transaction failing after the eth is unwrapped but just when sending ether to the proxy instance: