Skip to content

Instantly share code, notes, and snippets.

@kiknaio
Created February 4, 2022 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiknaio/7b70aa400e4dfdf15013629fa555843e to your computer and use it in GitHub Desktop.
Save kiknaio/7b70aa400e4dfdf15013629fa555843e to your computer and use it in GitHub Desktop.
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