Skip to content

Instantly share code, notes, and snippets.

@z0r0z
Created October 30, 2021 18:25
Show Gist options
  • Save z0r0z/f9851b98eeb197594b6c76b6e7923394 to your computer and use it in GitHub Desktop.
Save z0r0z/f9851b98eeb197594b6c76b6e7923394 to your computer and use it in GitHub Desktop.
EIP-1238 token built on OpenZeppelin
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
contract BadgeVotes is ERC20, ERC20Burnable, Ownable, ERC20Permit, ERC20Votes {
constructor() ERC20("Badge Votes", "BADGE") ERC20Permit("Badge Votes") {}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
// EIP-1238 overrides for non-transferability.
function transfer(address, uint256) public pure override returns (bool) {
revert();
}
function transferFrom(address, address, uint256) public pure override returns (bool) {
revert();
}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._afterTokenTransfer(from, to, amount);
}
function _mint(address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._mint(to, amount);
}
function _burn(address account, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._burn(account, amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment