Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getter for decimals to IERC20.sol #2559

Closed
CrackerHax opened this issue Mar 4, 2021 · 3 comments · Fixed by #2561
Closed

Add getter for decimals to IERC20.sol #2559

CrackerHax opened this issue Mar 4, 2021 · 3 comments · Fixed by #2561

Comments

@CrackerHax
Copy link

🧐 Motivation
Could use a getter for decimals()
📝 Details
IERC20 = IERC20(address);
uint decimals = token.decimals();

@abcoathup abcoathup changed the title openzeppelin-contracts/contracts/token/ERC20/IERC20.sol could use decimals() Add getter for decimals to IERC20.sol Mar 4, 2021
@abcoathup
Copy link
Contributor

Hi @CrackerHax,

Thanks for the suggestion, it is really appreciated.

The project owner will review your suggestion as soon as they can.

Please wait until we have discussed this idea before writing any code or submitting a Pull Request, so we can go through the design beforehand. We don’t want you to waste your time!

Can you describe your use case for an interface including optional ERC20 metadata such as decimals?

IERC20 is the interface of the ERC20 standard as defined in the EIP.
From: https://docs.openzeppelin.com/contracts/3.x/api/token/erc20#IERC20

Decimals is optional in the EIP: https://eips.ethereum.org/EIPS/eip-20

@Amxx
Copy link
Collaborator

Amxx commented Mar 4, 2021

Hello @CrackerHax and thank you for raising this issue,

Despite their wide availability, name, symbol and decimals are not actually part of the ERC20 standard. Many ERC20 token do not implement them, and this is why we did include these functions in the ERC20 interface.

An option could be to provide an extension interface ERC20Metadata That would extend IERC20 and provide these describe functions. Would that be a good enought solution for you ?

@frangio would you be ok with that ?

@frangio
Copy link
Contributor

frangio commented Mar 4, 2021

These functions are standard (they are part of ERC20) but they're optional, this is why they're not in the IERC20 interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants