Skip to content

Instantly share code, notes, and snippets.

@JuanXavier
Created July 14, 2022 22:01
Show Gist options
  • Select an option

  • Save JuanXavier/9f33252d879e463a97d9ca0368bc74f6 to your computer and use it in GitHub Desktop.

Select an option

Save JuanXavier/9f33252d879e463a97d9ca0368bc74f6 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/access/AccessControl.sol';
/**
* @title RewardToken
* @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz)
* @dev A mintable ERC20 with 2 decimals to issue rewards
*/
contract RewardToken is ERC20, AccessControl {
bytes32 public constant MINTER_ROLE = keccak256('MINTER_ROLE');
constructor() ERC20('Reward Token', 'RWT') {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(MINTER_ROLE, msg.sender);
}
function mint(address to, uint256 amount) external {
require(hasRole(MINTER_ROLE, msg.sender));
_mint(to, amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment