# ERC20 metadata and ERC20Detailed

**URL:** <https://forum.openzeppelin.com/t/erc20-metadata-and-erc20detailed/6200>\
**Category:** Contracts\
**Created:** [March 10, 2021, 7:39pm UTC](https://forum.openzeppelin.com/t/erc20-metadata-and-erc20detailed/6200 "2021-03-10T19:39:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [March 12, 2021, 3:16am UTC](https://forum.openzeppelin.com/t/erc20-metadata-and-erc20detailed/6200/4 "2021-03-12T03:16:56Z")

</div>

> [@jaureguino](#):
>
> Since I need to deploy my contracts ASAP, I would most likely be using OpenZeppelin 3.x. Do I install it with

You can install the latest release with

```auto
npm install @openzeppelin/contracts@solc-0.7

```

This will install OpenZeppelin Contracts 3.4.1 for Solidity 0.7

> [@jaureguino](#):
>
> The reason I have a constructor with minting stages is because I need to ensure that certain supplies exists at different times. Can I replace my logic by simply calling the 3.x \_mint function when I require it with the amount I require it?

It really depends on your use case. Can you mint all of the tokens initially and then lock them, or do you need to mint at the predefined stages.

> [@jaureguino](#):
>
> I need to set a maximun supply of tokens that will ever be minted. Would the **ERC20Capped** extension be used for this purpose and how? I would like to set up a 1.000.000 Tokens as Maximun Supply.

ERC20Capped does this by checking the cap before minting.

> [@jaureguino](#):
>
> I must ensure that the contract creator is the ONLY address able to mint, pause and possibly burn.

You can do this with Access Control, either Ownable or Roles: [https://docs.openzeppelin.com/contracts/3.x/access-control](https://docs.openzeppelin.com/contracts/3.x/access-control)

Using ERC20PresetMinterPauser the deployer is given the minter and pauser roles.

You also need to appropriately secure these admin accounts:

> **[Preparing for mainnet - OpenZeppelin Docs](https://docs.openzeppelin.com/learn/preparing-for-mainnet#key-management)**

> [@jaureguino](#):
>
> - Is the \_burn function automatically available when deplying ERC20 or is it only available with ERC20Burnable? Are they different things? What is the difference?

It is available if you extend from ERC20Burnable or add functionality to call `_burn`

> [@jaureguino](#):
>
> Could you please confirm the latest and greatest the **Flattening Process** at the end.

I recommend multifile verification rather than flattening: [How to verify with Hardhat or Truffle a smart contract using OpenZeppelin Contracts](https://forum.openzeppelin.com/t/verify-smart-contract-inheriting-from-openzeppelin-contracts/4119)

I would use flattening as a last resort.

* * *

⚠ I am a Community Manager and not a Security Researcher.  
Any contracts with value should be appropriately tested and audited.

* * *

You only need to extend from `ERC20PresetMinterPauser` and `ERC20Capped`  
For custom (non-18 decimals) you can use `_setupDecimals`

```auto
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Capped.sol";

contract MyToken is ERC20PresetMinterPauser, ERC20Capped {
    constructor (uint256 cap) ERC20PresetMinterPauser("MyToken", "TKN") ERC20Capped(cap) {
        _setupDecimals(9);
        _mint(msg.sender, 9000 * (10 ** uint256(decimals())));
    }
    
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20PresetMinterPauser, ERC20Capped) {
        super._beforeTokenTransfer(from, to, amount);
    }
}

```

* * *

As an aside, you can [Format code in the forum](https://forum.openzeppelin.com/t/format-code-in-the-forum/5424).

---

_[View the full topic](https://forum.openzeppelin.com/t/erc20-metadata-and-erc20detailed/6200)._
