Created
August 6, 2022 19:28
-
-
Save casweeney/4d9f02f1c40203519ae8a0bf49f7bc4b to your computer and use it in GitHub Desktop.
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: GPL-3.0 | |
| pragma solidity 0.8.4; | |
| import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; | |
| contract Erc20Token is ERC20("Chop I Chop", "CIC") { | |
| address owner; | |
| constructor() { | |
| owner = msg.sender; | |
| _mint(address(this), 10000e18); | |
| } | |
| function withdraw(address _address, uint amount) external { | |
| require(msg.sender == owner, "Not owner"); | |
| require(_address != address(0), "Can't withdraw to zero address"); | |
| uint balance = balanceOf(address(this)); | |
| require(balance >= amount, "Insufficient funds in contract"); | |
| _transfer(address(this), _address, amount); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment