# WETH(包装以太坊) **Published by:** [web3zoom](https://paragraph.com/@web3zoom/) **Published on:** 2025-10-01 **URL:** https://paragraph.com/@web3zoom/weth ## Content 遵守ERC20协议,将以太坊协议包装在WETH中,可以实现所有的以太坊方法。 继承Openzepplin协议// SPDX-License-Identifier: MIT pragma solidity ^0.8.30; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; contract WETH is ERC20, ERC20Burnable, Ownable{ event Deposit(address indexed account, uint amount); event Withdraw(address indexed account, uint amount); constructor(address initialOwner) ERC20("MyToken", "MTK") Ownable(initialOwner) {} fallback() external payable { deposit(); } function mint(address to, uint256 amount) public onlyOwner { _mint(to, amount); } function deposit() public payable { _mint(msg.sender, msg.value); emit Deposit(msg.sender, msg.value); } function withdraw(uint _amount) external { _burn(msg.sender, _amount); payable(msg.sender).transfer(_amount); emit Withdraw(msg.sender, _amount); } } ## Publication Information - [web3zoom](https://paragraph.com/@web3zoom/): Publication homepage - [All Posts](https://paragraph.com/@web3zoom/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@web3zoom): Subscribe to updates - [Twitter](https://twitter.com/primer2011): Follow on Twitter