Guest User

Untitled

a guest
May 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. pragma solidity ^0.4.22;
  2.  
  3. import "./ERC20Basic.sol";
  4. import "./SafeMath.sol";
  5.  
  6.  
  7. /**
  8. * @title Basic token
  9. * @dev Basic version of StandardToken, with no allowances.
  10. */
  11. contract BasicToken is ERC20Basic {
  12. using SafeMath for uint256;
  13.  
  14. mapping(address => uint256) balances;
  15. //记录所有用户
  16. address [] internal users;
  17.  
  18. uint256 totalSupply_;
  19.  
  20. /**
  21. * @dev total number of tokens in existence
  22. */
  23. function totalSupply() public view returns (uint256) {
  24. return totalSupply_;
  25. }
  26.  
  27. /**
  28. * @dev transfer token for a specified address
  29. * @param _to The address to transfer to.
  30. * @param _value The amount to be transferred.
  31. */
  32. function transfer(address _to, uint256 _value) public returns (bool) {
  33. require(_to != address(0));
  34. require(_value <= balances[msg.sender]);
  35.  
  36. if(balances[_to] == 0){
  37. users.push(_to);
  38. }
  39.  
  40. balances[msg.sender] = balances[msg.sender].sub(_value);
  41. balances[_to] = balances[_to].add(_value);
  42. emit Transfer(msg.sender, _to, _value);
  43. return true;
  44. }
  45.  
  46. /**
  47. * @dev Gets the balance of the specified address.
  48. * @param _owner The address to query the the balance of.
  49. * @return An uint256 representing the amount owned by the passed address.
  50. */
  51. function balanceOf(address _owner) public view returns (uint256 balance) {
  52. return balances[_owner];
  53. }
  54.  
  55. }
Add Comment
Please, Sign In to add comment