Solidity 0.6.0 introduced a breaking change in how ETH transfers are performed. The following doesn't work anymore:


What is the latest syntax for depositing ETH into the WETH contract?

  • weth.deposit{value: amount}(); as far as I remember. Nov 23 '20 at 16:59
  • And BTW, WETH is not a fundamental part of the Ethereum standard or infrastructure. It's an ERC20 contract implemented by a "privately held" company. So the question here is generally for any payable function on any contract (I mean, that's how the question should be formulated IMO). Nov 23 '20 at 17:01
  • @goodvibration It depends on your standards, but to me holding 5,411,942 ETH (approximately $316M at the time of writing this) makes WETH a rather important public good in the Ethereum ecosystem. Nov 23 '20 at 17:08
  • I included WETH in the formulation because I wanted this q&a to be very specific. Humans like specific examples. There is already another thread about payable functions in general. Nov 23 '20 at 17:09

Solidity 0.6 and 0.7

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 }();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.