Created
January 6, 2021 06:51
-
-
Save riordant/5f4a677c040d51aaf73ddd71efcad158 to your computer and use it in GitHub Desktop.
OpenZeppelin ERC20 token with changeable name/symbol
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
pragma solidity ^0.5.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/token/ERC20/ERC20.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/token/ERC20/ERC20Detailed.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/ownership/Ownable.sol"; | |
contract Token is ERC20, ERC20Detailed, Ownable { | |
string private _name = "DAOMaker Token"; | |
string private _symbol = "DAO"; | |
uint constant _numTokens = 1000000; | |
event NameChanged(string newName, address by); | |
event SymbolChanged(string newSymbol, address by); | |
constructor () public ERC20Detailed(_name, _symbol, 18) { | |
_mint(msg.sender, _numTokens * (10 ** uint256(decimals()))); | |
} | |
function changeName(string memory name) public onlyOwner{ | |
_name = name; | |
emit NameChanged(name, msg.sender); | |
} | |
function name() public view returns (string memory) { | |
return _name; | |
} | |
function changeSymbol(string memory symbol) public onlyOwner { | |
_symbol = symbol; | |
emit SymbolChanged(symbol, msg.sender); | |
} | |
function symbol() public view returns (string memory) { | |
return _symbol; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment