Help creating an ERC20 token using Remix

Hey OpenZeppelin community!

I’m totally new at playing around with smart-contract and token creation, and not the strongest coder. I am therefore playing with Remix and the Open zeppelin.

I have a few questions, and a few issues I was hoping to get help with.

The base of what I’m using was coming from this guide. So I would have the same setup as prior guide and have been playing around with it to create some coins.

First:

I choose the prior guide’s setup as it has the 3 key essentials I needed, Pause, Burn and mint.

Is there anything I should be aware of other than setting the Decimals, symbol and name? - Or is there some setup needed to be done inside the Git repo of the open zeppelin contract I’m inserting from for prober use? - I assume the owner of the contract is the contract creator as calling the contract from another wallet wouldn’t allow you to mint, burn or pause, or anything else for that sake?

Second

The first issue stumbled upon is the following:

I didn’t have issues with burning or minting in general, but if I tried using the “burnFrom” method, which would have me choose a specific wallet to burn from it would always give me an error stating I didn’t have enough gas allowance, raising gas would never help:

Screenshot 2020-06-29 at 11.35.38

How do I fix this?

Third

I’m trying to figure out how to “grantRole” which I assume is admin role to interact with the smart contract. I’m not so sure what to insert in the role: box, as I only get errors no matter what I write, as I’m only guessing.

Also is it possible to give a MEW wallet admin role? and how would I call the contract from remix without using MetaMask?

I appreciate the effort of allowing such tools to have someone like me create smart-contract comprehensible, now I just need to understand the missing parts.

Thanks in advance

Kindest Regards

Felix Theodoor

1 Like

Note: using the regular burn method, which does not state which address and just burn them from the contract owner works fine.

1 Like

Hi @Felix_Theodoor,

Welcome to the community :wave:

I recommend going through Points to consider when creating a fungible token (ERC20, ERC777)

It is important to understand what the different roles are:

https://docs.openzeppelin.com/contracts/3.x/api/presets#ERC20PresetMinterPauser
The account that deploys the contract will be granted the minter and pauser roles, as well as the default admin role, which will let it grant both minter and pauser roles to other accounts.

For more information on roles see the AccessControl documentation.

Also, it is possible to create a simple ERC20 contract with a fixed supply, and no minting, pausing or burning. Deploy a simple ERC20 token in Remix

To use burnFrom the account calling this function needs to have an allowance (of tokens) set by the token holder so that they can burn them on their behalf. See the API documentation:

https://docs.openzeppelin.com/contracts/3.x/api/token/erc20#ERC20Burnable-burnFrom-address-uint256-
the caller must have allowance for accounts's tokens of at least amount.

The MINTER_ROLE is the hash of the string "MINTER_ROLE".
See the code: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/presets/ERC20PresetMinterPauser.sol#L26

It's value can be read by calling MINTER_ROLE. The value is: 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6

Using the guide, you are using a local blockchain. You would need to deploy to a public testnet so that you could access from other applications such as MEW.

If you are new to public testnets I suggest looking at Connecting to Public Test Networks to learn some of the concepts.

You would need to use Injected Web3 using MetaMask or another web3 provider and deploy to a public testnet.


Feel free to ask the questions that you need.

1 Like

Hi @abcoathup

Thank you for your reply.

I've read through your links thank you, It does not completely clarify my questions, but that's maybe just because I'm not experienced enough.

As far as I understand it that the default_admin_role has a value of:
(Does this mean any wallet can interact with my smart contract at the moment?)

0x0000000000000000000000000000000000000000000000000000000000000000

While the Minter role has the value of:
(Does the minter role also provide the ability to burn tokens?)

0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6

and the pausing role has the value of:

0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a

So basically that's the value I can put into the role box to define what role I would give a wallet calling the contract?

are there other roles with the value I can play around with as I couldn't find values for more than the abovestated?


Regarding the burnFrom method, I understood it as being able to burn tokens from other wallets?

I tried increasing my allowance, but it did not allow me to do the burnFrom and still told me my allowance wasn't set right... Could you guide me in simple man language how I could achieve this right?


I actually already was using injected Web3 with metamask on a testnet, and didn't play around with the local blockchain. I assume if I had my Metamask on the mainnet that everything I would do would actually create real tokens on the real blockchain? which is what the end-goal is when I feel I understand how to call the contract right.

That's why I tried to figure out how I would call the contract in remix with an MEW wallet instead and do basically the same I'm doing now with metamask.

Is that achievable? If yes could you guide me?

Thank you for your reply, it's highly appreciated!

Kindest regards

1 Like

Hi @Felix_Theodoor,

The ERC20PresetMinterPauser has three roles:

https://docs.openzeppelin.com/contracts/3.x/api/presets#ERC20PresetMinterPauser-constructor-string-string-
Grants DEFAULT_ADMIN_ROLE, MINTER_ROLE and PAUSER_ROLE to the account that deploys the contract.

An account with the Minter role can mint tokens.
An account with the Pauser role can pause the token.
An account with the Default Admin role can grant or revoke roles.

There isn't a burner role. Accounts can burn their own tokens or give an allowance of tokens that another account can burn.


burnFrom can be used to burn tokens where the holder of the tokens has given an allowance to the account.

If Account A holds tokens, they can approve an allowance to Account B
Account B can then call burnFrom to burn Account A tokens for an amount within their allowance.


I haven't used MEW so I don't know what functionality it has (or how keys are stored).

Thanks for the help.

If i would have to verify my contract on etherscan, would i have to paste the code from ERC20PresetminterPause.sol ? or how would i do that correctly :slight_smile: ?

Thanks in advance

EDIT:

Finally found the answer here:

2 Likes