Request: Example of a Mintable and Pausable ERC20 token

Hey Everyone!

I am currently learning to develop ERC20 Tokens.
I was wondering if there is an example of a Mintable and Pausable ERC20 Token Contract.

1 Like

Hi @niru.kun14,

Welcome to the community :wave:. Thanks for posting here.

I have created an example of an ERC20 token inheriting from ERC20Mintable and ERC20Pausable extensions, with pause also pausing the mint function.

The following code hasn’t been tested, and if you use this code, it should be appropriately tested and audited.


pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";

contract MyToken is ERC20, ERC20Detailed, ERC20Mintable, ERC20Pausable {
    constructor() ERC20Detailed("MyToken", "TKN", 18) public {

    function mint(address account, uint256 amount) public whenNotPaused returns (bool) {
        return, amount);

Thank you very much @abcoathup. I will now proceed to the testing of this example.

1 Like

Hi @niru.kun14,

Feel free to ask all the questions that you need.

I ran a couple of manual checks using Remix but it needs thorough testing.

1 Like

Hi, I have been thinking about using this approach for my current project. Only one issue, these “ERC20Mintable”, “ERC20Detailed”, and “ERC20Pausable” modules aren’t available in OpenZeppelin Contracts v3.x. But, I can do that by using v2.x. Is it okay to use v2.x in July 2020?

1 Like

Hi @PradhumnaPancholi,

Whilst you can still use OpenZeppelin Contracts 2.x, I would suggest using OpenZeppelin Contracts 3.x.

You can use the preset ERC20 contract as is or you can create your own inheriting from either the preset or from ERC20. As per my other reply: How to create a mintable ERC20 token?

1 Like

Thanks, I did it some other way for gig I was doing when I asked the question. But, now I think I have better understating of OpenZeppelin’s ERC20 modules and pressets. And I would do to in my upcoming gigs.

1 Like