Skip to content

Instantly share code, notes, and snippets.

@kmjones1979
Last active July 3, 2024 14:53
Show Gist options
  • Save kmjones1979/0509efaf14e952d3164f508af51ff539 to your computer and use it in GitHub Desktop.
Save kmjones1979/0509efaf14e952d3164f508af51ff539 to your computer and use it in GitHub Desktop.
Simple ERC20 contract example for the Hackathon Prep Brunch workshop in Brussels
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import "hardhat/console.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* A smart contract for a workshop during EthCC
* @author Kevin Jones
*/
contract YourContract is Ownable {
string public name = "WIF";
string public symbol = "WIF";
uint8 public decimals = 18;
uint256 public totalSupply = 21000000 * (10 ** uint256(decimals));
mapping(address => uint256) public balanceOf;
event Transfer(address indexed from, address indexed to, uint256 value);
constructor() {
balanceOf[0x7B31e0753C750EaC5F7DC88F677B49C06E7f8D2B] = totalSupply;
emit Transfer(address(0), 0x7B31e0753C750EaC5F7DC88F677B49C06E7f8D2B, totalSupply);
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value, "Insufficient balance");
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
function withdrawl() public onlyOwner {
uint256 balance = address(this).balance;
(bool success, ) = payable(owner()).call{value: balance}("");
require(success, "Transfer failed.");
}
receive() external payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment