Is Ticker string parameter for ERC20Detailed optional?

I have two questions.

1- I read the documentation, but couldn't be sure of the following: Is the token ticker string parameter option for the ERC20Detailed contract? If not, is there a way around this? As in my application, I just need the token name but not the ticker.

2- I pass the tokenName string as a parameter to my ERC20 token contract implementation, i.e. pass it to its constructor. The reason being is because the ERC20 token is deployed via a Factory contract. So the Factory contract calls the ERC20 constructor and passes the token name parameter to it. So since inheriting the ERC20Detailed requires calling its constructor, is there a way to pass the tokenName string parameter from my ERC20 constructor and to the ERC20Detailed constructor? Please refer to the code below of what I'm trying to achieve.

:1234: Code to reproduce

pragma solidity ^0.4.17;

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol'; 

contract MyToken is ERC20, ERC20Detailed {

// I did not include the token ticker parameter in the ERC20Detailed. Will this throw an error?
// Also, can I pass the `tokenName` parameter from the ERC20 constructor to ERC20Detailed?
  constructor(tokenName) ERC20Detailed(tokenName, 18) {



:computer: Environment

Visual Studio Code editor.

// I did not include the token ticker parameter in the ERC20Detailed. Will this throw an error?

yes, pass an empty string for the ticker if you don't need it but I do not recommend not using a ticker because a lot of apps display tokens using their ticker name so if you don't have a ticker, it might look weird / have issues w/ integration onto certain platforms.

// Also, can I pass the tokenName parameter from the ERC20 constructor to ERC20Detailed?


Separately, you should use the latest version of the openzeppelin contracts.


Thanks for your quick response @STYJ .

The thing is my application will have the cryptocurrency traded internally. It will not trade with other exchanges/DApps outside of my DApp. So will the ticker still be needed in this case?

With regards to the second question, so just to confirm, if MyToken contract, which is deployed by a Factory contract, is passed the tokenName as an argument to its constructor, we can pass this argument to the ERC20Detailed constructor as well (as per the code example), and it won't throw an error?

I have used npm to install openzeppelin, so I take it I'm using the latest version!! I changed the solidity compiler version to ^0.8.0. So will this suffice?

Many thanks

It seems like you use a old version of the @openzeppelin/contracts, and I assume that use this version: ERC20Detailed.sol at release-v2.5.0, and you can see, in this version, the constructor is defined as following:

constructor (string memory name, string memory symbol, uint8 decimals) public {
    _name = name;
    _symbol = symbol;
    _decimals = decimals;

So even though you do not want to use a symbol for the contract, this parameter is still needed, that is ERC20Detailed(tokenName, "", 18), so no matter how do you generate a new ERC20Detailed() contract, you need to pass three parameters.

And if you upgrade your contracts from 0.4.x to 0.8.x, maybe you need to make some changes, cause there are some changes in grammar.

1 Like

Thanks for your response @Skyge .

I've had a look at my package.json and it lists "@openzeppelin/contracts": "^4.3.1",. Apologies if I'm coming across naive but how can you tell what @openzeppelin/contracts version I'm using just from looking at my code example? I'm just curious.

Of course, I will definitely pass an empty string to the ticker argument (as it is a required parameter). I was just asking if it's necessary to specify an actual ticker value (not an empty string), when my token is only going to be used internally in my DApp, and won't interact/integrate with other exchanges/DApps.

Thank you for the heads-up :slight_smile:

Yeah, the vesion is just defined in your package.json

It is up to you, you can pass everything for your token. Generally, we would like to pass a readable value for token symbol

1 Like