Created
February 8, 2023 05:37
-
-
Save puneetkaura/f8da3388b6331f9cd7b1acaf27050553 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.17+commit.8df45f5f.js&optimize=false&runs=200&gist=
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
import "hardhat/console.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC20Capped.sol"; | |
// ERC20 with god mode. A special address is able to transfer tokens between addresses at will. | |
contract GodModeERC20 is ERC20, ERC20Capped { | |
uint private constant CAP_AMOUNT = 100_000_000; | |
address public immutable GOD; | |
constructor(address _godAddress) ERC20("GOD", "GOD") ERC20Capped(CAP_AMOUNT) { | |
GOD=_godAddress; | |
} | |
modifier onlyGOD() { | |
require (msg.sender == GOD, "Only GOD"); | |
_; | |
} | |
event GodTxfer(address from, address to, uint amount); | |
function _mint(address to, uint256 amount) internal override(ERC20, ERC20Capped){ | |
super._mint(to, amount); | |
} | |
// Anyone can mint any number of tokens till cap is reached | |
function mint(uint _amount) external returns(bool){ | |
_mint(msg.sender, _amount); | |
return true; | |
} | |
// God can txfer any amount of tokens from A --> B (Txfer amount should be less than A owned Tokens) | |
function godTransfer(address _from, address _to, uint _amount) external onlyGOD returns(bool){ | |
_transfer(_from, _to, _amount); | |
emit GodTxfer(_from, _to, _amount); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment