2

I have a localhost Hardhat Network running but I need to convert Fake ETH on it into WETH. How can I do this?

enter image description here

1 Answer 1

1

I think the easiest way to do this is to create an ERC20 called WETH. Something like:

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.4;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract WETHToken is ERC20 {
    constructor() ERC20("Wrapped ETHER", "WETH") {
        _mint(<msg.sender or your address>, 9999 ether);
    }
}

So when you npx hardhat node, you'll have to deploy that contract.

1
  • I'm running off a fork of mainnet and need to use the actual WETH contract, so this wasn't an option for me.
    – erb
    Commented May 22 at 13:09

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.