BasicToken.sol 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. pragma solidity ^0.4.18;
  2. import "./ERC20Basic.sol";
  3. import "../../math/SafeMath.sol";
  4. /**
  5. * @title Basic token
  6. * @dev Basic version of StandardToken, with no allowances.
  7. */
  8. contract BasicToken is ERC20Basic {
  9. using SafeMath for uint256;
  10. mapping(address => uint256) balances;
  11. uint256 totalSupply_;
  12. /**
  13. * @dev total number of tokens in existence
  14. */
  15. function totalSupply() public view returns (uint256) {
  16. return totalSupply_;
  17. }
  18. /**
  19. * @dev transfer token for a specified address
  20. * @param _to The address to transfer to.
  21. * @param _value The amount to be transferred.
  22. */
  23. function transfer(address _to, uint256 _value) public returns (bool) {
  24. require(_to != address(0));
  25. require(_value <= balances[msg.sender]);
  26. // SafeMath.sub will throw if there is not enough balance.
  27. balances[msg.sender] = balances[msg.sender].sub(_value);
  28. balances[_to] = balances[_to].add(_value);
  29. Transfer(msg.sender, _to, _value);
  30. return true;
  31. }
  32. /**
  33. * @dev Gets the balance of the specified address.
  34. * @param _owner The address to query the the balance of.
  35. * @return An uint256 representing the amount owned by the passed address.
  36. */
  37. function balanceOf(address _owner) public view returns (uint256 balance) {
  38. return balances[_owner];
  39. }
  40. }