# Creating an ERC-20 token with OpenZeppelin v3.x?

**URL:** <https://forum.openzeppelin.com/t/creating-an-erc-20-token-with-openzeppelin-v3-x/3950>\
**Category:** Contracts\
**Created:** [September 27, 2020, 5:31am UTC](https://forum.openzeppelin.com/t/creating-an-erc-20-token-with-openzeppelin-v3-x/3950 "2020-09-27T05:31:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PradhumnaPancholi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/pradhumnapancholi/32/2809_2.png) [@PradhumnaPancholi](https://forum.openzeppelin.com/u/PradhumnaPancholi)\
**Post date:** [September 27, 2020, 5:31am UTC](https://forum.openzeppelin.com/t/creating-an-erc-20-token-with-openzeppelin-v3-x/3950/1 "2020-09-27T05:31:48Z")

</div>

Hi everyone. So, I have developed both an ERC20 and ERC721 token using OpenZeppelin 2.x but now, I am onto something where I have to build an ERC20 token using OpenZeppelin 3.x. Can someone point me in the right direction? Also, I wanna understand OpenZeppelin 3.x more as I am on a project which is at a much larger scale and I will be developing and maintaining a couple of tokens in the next 7-8 months.

Edit:- I can create a basic ERC-20 token with it but I struggle with things like using functionalities from ‘access’ to make it ownable, making it mintable, and things like that.

---

<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:** [September 28, 2020, 2:28am UTC](https://forum.openzeppelin.com/t/creating-an-erc-20-token-with-openzeppelin-v3-x/3950/2 "2020-09-28T02:28:02Z")

</div>

Hi @PradhumnaPancholi,

I suggest looking at AccessControl rather than Ownable so that you can define roles for specific actions (such as minting).  
See the documentation for details: [https://docs.openzeppelin.com/contracts/3.x/access-control#role-based-access-control](https://docs.openzeppelin.com/contracts/3.x/access-control#role-based-access-control)

ERC20PresetMinterPauser is an example of using AccessControl for minting and pausing:

> <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/presets/ERC20PresetMinterPauser.sol>

As well as access control, you could look at using hooks (depending on what functionality you need): [https://docs.openzeppelin.com/contracts/3.x/extending-contracts#using-hooks](https://docs.openzeppelin.com/contracts/3.x/extending-contracts#using-hooks)

Whenever someone is creating a token, I suggest they look at: [Points to consider when creating a fungible token (ERC20, ERC777)](https://forum.openzeppelin.com/t/points-to-consider-when-creating-a-fungible-token-erc20-erc777/2915)

Feel free to ask all the questions that you need.

---

<div class="post-metadata">

**Author:** ![PradhumnaPancholi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/pradhumnapancholi/32/2809_2.png) [@PradhumnaPancholi](https://forum.openzeppelin.com/u/PradhumnaPancholi)\
**Post date:** [September 29, 2020, 8:03am UTC](https://forum.openzeppelin.com/t/creating-an-erc-20-token-with-openzeppelin-v3-x/3950/3 "2020-09-29T08:03:55Z")

</div>

I spent a quite a good amount of time in Access Control and I think I get most of it now but for this project, I think Ownable is better way bcoz we are allowing very few things that can be done by user.To follow up on that, if I out “onlyOwner” on my constrcutor, does it apply on all methods? and second question is more basic, if I wanna sell a token as single unit i.e no “1.5455”, it’s just 1000 tokens sold as single units, does my decimal value needs to be “0”?

---

<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:** [September 29, 2020, 8:38am UTC](https://forum.openzeppelin.com/t/creating-an-erc-20-token-with-openzeppelin-v3-x/3950/4 "2020-09-29T08:38:23Z")

</div>

Hi @PradhumnaPancholi,

My suggestion is to use Access Control, even if the only privileged function is mint. Where possible it is best to avoid having an all encompassing privileged function.

You don’t need `onlyOwner` on your constructor, you only need to add the modifier on functions that you only want the owner to call. (see the example in the documentation: [https://docs.openzeppelin.com/contracts/3.x/access-control#ownership-and-ownable](https://docs.openzeppelin.com/contracts/3.x/access-control#ownership-and-ownable))

If you want no decimals, then set decimals to zero. You will need to call [\_setupDecimals](https://docs.openzeppelin.com/contracts/3.x/api/token/erc20#ERC20-_setupDecimals-uint8-) if you aren’t using the default of zero.
