'Solidity: WETH can't be extracted

I can convert ETH to WETH via WETH smart contract and deposit it in my smart contract address, but when I want to convert WETH in my smart contract address to ETH via WETH smart contract and withdraw it to my wallet address, I can't do it.

pragma solidity ^0.5.0;
interface IWETH {
    function deposit() external payable;
    function transfer(address to, uint value) external returns (bool);
    function withdraw(uint256 value) external payable;

}

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract testwithdraw {
    uint256 public ETHAnt;
    address public WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;  

    function deposit() public payable{
        ETHAnt = msg.value;      
        IWETH(WETH).deposit.value(ETHAnt)();
    }

    function getContractBalance(address _to) public view returns(uint) {
       uint256 Balance = IERC20(WETH).balanceOf(_to);
       return Balance;
    }

    function withdraw(uint256 _value) public payable { 
        IWETH(WETH).withdraw.value(_value);
    }
}

When using the withdraw function, it tells me that it ran successfully. But I see that the from in the log is actually my wallet address, and the to is my smart contract address. What's going on here?

status  true Transaction mined and execution succeed
transaction hash    0x2859b5188b12cb2f0849a26777a5d2d0972e0e2ce000b548b80f3e5ae3b85b32
from    0xAb2942DEcDEa92A43d84DE7097a2e8df373e41Ab
to  testwithdraw.withdraw(uint256) 0xa5f43d3A0C3ee2A99511A14698F0DB082491C751
gas 22323 gas
transaction cost    22323 gas 
hash    0x2859b5188b12cb2f0849a26777a5d2d0972e0e2ce000b548b80f3e5ae3b85b32
input   0x2e1...00000
decoded input   {
    "uint256 _value": "1000000000000000000000"
}
decoded output   - 
logs    []
val 0 wei


Solution 1:[1]

When you're withdrawing ETH using IWETH(WETH).withdraw.value(_value), it withdraws ETH from WETH contract and stores them on your contract. In order to be able to withdraw received funds, you need to add something like payable(msg.sender).transfer(address(this).balance) in your withdraw function.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Artem