Looking at the contract for Wrapped Ether, I noticed that it uses a function called deposit
to wrap ETH.
The function deposit
itself does not get an argument. However, at the top of the script, I noticed event Deposit(address indexed dst, uint wad);
I suppose I have to create this event with the proper arguments (wallet address and how much to be wrapped). I am not sure how to create this event when, I think, I can only interact with functions within the contract.
I am trying to do this in web3.py. I was able to successfully unwrap an existing wETH by calling the withdraw
function in the wETH contract.
Best Answer
You just have to call the deposit() function of the WETH contract and define the number of ETH to be wrapped to WETH in the transaction's
value
key.Example of working, unsigned tx:
As an alternative, you can just send ethers to the smart contract's address, as a normal transfer between two accounts. The contract has a fallback function
function() public payable
that will take care of all the logic because it actually callsdeposit()
.