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. Commented Nov 23, 2020 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). Commented Nov 23, 2020 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. Commented Nov 23, 2020 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. Commented Nov 23, 2020 at 17:09

1 Answer 1


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 }();
  • Hello. I have followed what you said, but the Weth is not transferred to user's wallet.
    – Yaya
    Commented Sep 24, 2022 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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