Pārlūkot izejas kodu

implement ERC20

邓心一 7 gadi atpakaļ
vecāks
revīzija
7c69c7c9c8
2 mainītis faili ar 21 papildinājumiem un 1 dzēšanām
  1. 17 0
      contracts/ERC20.sol
  2. 4 1
      contracts/ShowTrader.sol

+ 17 - 0
contracts/ERC20.sol

@@ -0,0 +1,17 @@
+pragma solidity ^0.4.23;
+
+// ----------------------------------------------------------------------------
+// ERC Token Standard #20 Interface
+// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
+// ----------------------------------------------------------------------------
+contract ERC20 {
+    function totalSupply() public view returns (uint);
+    function balanceOf(address tokenOwner) public view returns (uint balance);
+    function allowance(address tokenOwner, address spender) public view returns (uint remaining);
+    function transfer(address to, uint tokens) public returns (bool success);
+    function approve(address spender, uint tokens) public returns (bool success);
+    function transferFrom(address from, address to, uint tokens) public returns (bool success);
+
+    event Transfer(address indexed from, address indexed to, uint tokens);
+    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
+}

+ 4 - 1
contracts/ShowTrader.sol

@@ -1,8 +1,11 @@
 pragma solidity ^0.4.23;
 
 import "./ShowOwnership.sol";
+import "./ERC20.sol";
+
+contract ShowTrader is ERC20, ShowOwnership {
+    uint private _totalSupply;
 
-contract ShowTrader is ShowOwnership {
     event Sell(uint id, uint price);
     event Buy(uint id);