How to implement ERC20 tokens?

Hi @asmeedhungana,

Sorry I haven’t gotten back to you sooner. It’s a busy week.

If I understand correctly you have three contracts:

  • A Token Factory
  • Tokens
  • And a merchant contract where the token can be used.

If you inherit from the OpenZeppelin Contracts implementation of ERC20 then you have a compatible ERC20 which implements all the required functions. If you use ERC20PresetMinterPauser then you would just need to add the account you want to be able to mint from. (the deployer of the contract, I assume the factory, would be the minter.)

For the Token Factory you could inherit from ProxyFactory

Given you are working on a game with multiple tokens you might want to look at using multi-token standard ERC1155 which is part of OpenZeppelin Contracts v3.1

1 Like