ERC20Detailed.sol 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. pragma solidity ^0.6.0;
  2. import "./IERC20.sol";
  3. /**
  4. * @dev Optional functions from the ERC20 standard.
  5. */
  6. abstract contract ERC20Detailed is IERC20 {
  7. string private _name;
  8. string private _symbol;
  9. uint8 private _decimals;
  10. /**
  11. * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
  12. * these values are immutable: they can only be set once during
  13. * construction.
  14. */
  15. constructor (string memory name, string memory symbol, uint8 decimals) public {
  16. _name = name;
  17. _symbol = symbol;
  18. _decimals = decimals;
  19. }
  20. /**
  21. * @dev Returns the name of the token.
  22. */
  23. function name() public view returns (string memory) {
  24. return _name;
  25. }
  26. /**
  27. * @dev Returns the symbol of the token, usually a shorter version of the
  28. * name.
  29. */
  30. function symbol() public view returns (string memory) {
  31. return _symbol;
  32. }
  33. /**
  34. * @dev Returns the number of decimals used to get its user representation.
  35. * For example, if `decimals` equals `2`, a balance of `505` tokens should
  36. * be displayed to a user as `5,05` (`505 / 10 ** 2`).
  37. *
  38. * Tokens usually opt for a value of 18, imitating the relationship between
  39. * Ether and Wei.
  40. *
  41. * NOTE: This information is only used for _display_ purposes: it in
  42. * no way affects any of the arithmetic of the contract, including
  43. * {IERC20-balanceOf} and {IERC20-transfer}.
  44. */
  45. function decimals() public view returns (uint8) {
  46. return _decimals;
  47. }
  48. }