BasicToken.sol 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. pragma solidity ^0.4.8;
  2. import './ERC20Basic.sol';
  3. import '../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 uint;
  10. mapping(address => uint) balances;
  11. /**
  12. * @dev Fix for the ERC20 short address attack.
  13. */
  14. modifier onlyPayloadSize(uint size) {
  15. if(msg.data.length < size + 4) {
  16. throw;
  17. }
  18. _;
  19. }
  20. /**
  21. * @dev transfer token for a specified address
  22. * @param _to The address to transfer to.
  23. * @param _value The amount to be transferred.
  24. */
  25. function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) {
  26. balances[msg.sender] = balances[msg.sender].sub(_value);
  27. balances[_to] = balances[_to].add(_value);
  28. Transfer(msg.sender, _to, _value);
  29. }
  30. /**
  31. * @dev Gets the balance of the specified address.
  32. * @param _owner The address to query the the balance of.
  33. * @return An uint representing the amount owned by the passed address.
  34. */
  35. function balanceOf(address _owner) constant returns (uint balance) {
  36. return balances[_owner];
  37. }
  38. }