Răsfoiți Sursa

add improvement in simpletoken example #1458 (#1473)

* add improvement in simpletoken example #1458

* fix not calling decimals get function in initial supply
LaimeJesus 7 ani în urmă
părinte
comite
1186520617
1 a modificat fișierele cu 4 adăugiri și 7 ștergeri
  1. 4 7
      contracts/examples/SimpleToken.sol

+ 4 - 7
contracts/examples/SimpleToken.sol

@@ -1,6 +1,7 @@
 pragma solidity ^0.4.24;
 
 import "../token/ERC20/ERC20.sol";
+import "../token/ERC20/ERC20Detailed.sol";
 
 /**
  * @title SimpleToken
@@ -8,18 +9,14 @@ import "../token/ERC20/ERC20.sol";
  * Note they can later distribute these tokens as they wish using `transfer` and other
  * `ERC20` functions.
  */
-contract SimpleToken is ERC20 {
+contract SimpleToken is ERC20, ERC20Detailed {
 
-  string public constant name = "SimpleToken";
-  string public constant symbol = "SIM";
-  uint8 public constant decimals = 18;
-
-  uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));
+  uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals()));
 
   /**
    * @dev Constructor that gives msg.sender all of existing tokens.
    */
-  constructor() public {
+  constructor() public ERC20Detailed("SimpleToken", "SIM", 18) {
     _mint(msg.sender, INITIAL_SUPPLY);
   }