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?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communitySolidity 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