github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/governance/GovernanceToken.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity 0.8.15; 3 4 import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; 6 import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; 7 import "@openzeppelin/contracts/access/Ownable.sol"; 8 9 /// @custom:predeploy 0x4200000000000000000000000000000000000042 10 /// @title GovernanceToken 11 /// @notice The Optimism token used in governance and supporting voting and delegation. Implements 12 /// EIP 2612 allowing signed approvals. Contract is "owned" by a `MintManager` instance with 13 /// permission to the `mint` function only, for the purposes of enforcing the token 14 /// inflation schedule. 15 contract GovernanceToken is ERC20Burnable, ERC20Votes, Ownable { 16 /// @notice Constructs the GovernanceToken contract. 17 constructor() ERC20("Optimism", "OP") ERC20Permit("Optimism") { } 18 19 /// @notice Allows the owner to mint tokens. 20 /// @param _account The account receiving minted tokens. 21 /// @param _amount The amount of tokens to mint. 22 function mint(address _account, uint256 _amount) public onlyOwner { 23 _mint(_account, _amount); 24 } 25 26 /// @notice Callback called after a token transfer. 27 /// @param from The account sending tokens. 28 /// @param to The account receiving tokens. 29 /// @param amount The amount of tokens being transfered. 30 function _afterTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Votes) { 31 super._afterTokenTransfer(from, to, amount); 32 } 33 34 /// @notice Internal mint function. 35 /// @param to The account receiving minted tokens. 36 /// @param amount The amount of tokens to mint. 37 function _mint(address to, uint256 amount) internal override(ERC20, ERC20Votes) { 38 super._mint(to, amount); 39 } 40 41 /// @notice Internal burn function. 42 /// @param account The account that tokens will be burned from. 43 /// @param amount The amount of tokens that will be burned. 44 function _burn(address account, uint256 amount) internal override(ERC20, ERC20Votes) { 45 super._burn(account, amount); 46 } 47 }