Skip to content

Instantly share code, notes, and snippets.

@casweeney
Created August 6, 2022 19:28
Show Gist options
  • Select an option

  • Save casweeney/4d9f02f1c40203519ae8a0bf49f7bc4b to your computer and use it in GitHub Desktop.

Select an option

Save casweeney/4d9f02f1c40203519ae8a0bf49f7bc4b to your computer and use it in GitHub Desktop.
// 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