Created
August 20, 2022 02:43
-
-
Save Hazelwu2/1505978593d2d55ec71c74590935e3fc to your computer and use it in GitHub Desktop.
基本題二 部署 ERC20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.4; | |
| import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
| contract HazelToken is ERC20 { | |
| // 調整 mint 數量,確定能夠拿到 10,000 個 ERC20 Token | |
| uint256 public initialSupply = 10000; | |
| // 嘗試修改 name 與 symbol | |
| constructor() ERC20("HazelToken", "HZ") { | |
| _mint(msg.sender, initialSupply); | |
| } | |
| // 添加一個功能並且傳送 n 個數量 ERC20 Token | |
| // 給二號(ex. 0x977e01DDd064e404227eea9E30a5a36ABFDeF93D)地址 | |
| function buyCoin(address _to, uint256 _amount) public { | |
| _mint(_to, _amount); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment