Solidity 0.6.0 introduced a breaking change in how ETH transfers are performed. The following doesn't work anymore:
weth.deposit.value(amount)();
What is the latest syntax for depositing ETH into the WETH contract?
Solidity 0.6.0 introduced a breaking change in how ETH transfers are performed. The following doesn't work anymore:
weth.deposit.value(amount)();
What is the latest syntax for depositing ETH into the WETH contract?
Here's a simple implementation that can you try out in Remix:
pragma solidity >=0.6.0;
interface WethLike {
function deposit() external payable;
function withdraw(uint256) external;
}
contract MyContract {
WethLike weth;
constructor(WethLike weth_) {
weth = weth_;
}
function foo() external payable {
weth.deposit{ value: msg.value }();
}
}
weth.deposit{value: amount}();as far as I remember. – goodvibration Nov 23 '20 at 16:59