I'm developing a contract that receives ERC20 tokens and need to know token name and token symbol.

According to the IERC20 in OppenZeppelin there is no public symbol() or name() functions. I know that these functions are automatically generated because symbol and name variables are public in every ERC20 token, but maybe not part of the interface.

I know that every ERC20 token will have symbol() and name() functions, so I could use IERC20Metadata or ERC20 contracts. I'm aware that is safer to instantiate the tokens from the interface, but not sure if IERC20Metadata will be valid for every ERC20 token. Which would be the best option?

Option 1:


Option 2:


1 Answer 1


No, you can't assume it will work for every token, as their untrusted and are not obligated to implement these methods.

As for working with IERC20Metadata vs ERC20Metadata, it's the same in term of API. The main difference would be that the latter would be compiled in your project while the interface will only be used by the compiler when building your contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.