Created
February 4, 2022 08:53
-
-
Save kiknaio/7b70aa400e4dfdf15013629fa555843e to your computer and use it in GitHub Desktop.
This file contains 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.8.7; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
contract SecurityHashrateToken is ERC20 { | |
address private owner; | |
mapping (address => bool) private authorized; | |
constructor(uint256 initialSupply) ERC20("SECURITYHASHRATE", "SHRTK") { | |
owner = msg.sender; | |
_mint(msg.sender, initialSupply); | |
} | |
function addAuthorizedAddress(address _authorizedAddress) public onlyOwner { | |
authorized[_authorizedAddress] = true; | |
} | |
function removeAuthorizedAddress(address _authorizedAddress) public onlyOwner { | |
authorized[_authorizedAddress] = false; | |
} | |
function transfer(address recipient, uint256 amount) public override returns (bool) { | |
require(authorized[recipient] == true, "Address should be authorized to receive tokens"); | |
_transfer(_msgSender(), recipient, amount); | |
return true; | |
} | |
modifier onlyOwner { | |
require(msg.sender == owner); | |
_; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment