BurnableToken.sol 846 B

12345678910111213141516171819202122232425262728
  1. pragma solidity ^0.4.18;
  2. import './StandardToken.sol';
  3. /**
  4. * @title Burnable Token
  5. * @dev Token that can be irreversibly burned (destroyed).
  6. */
  7. contract BurnableToken is StandardToken {
  8. event Burn(address indexed burner, uint256 value);
  9. /**
  10. * @dev Burns a specific amount of tokens.
  11. * @param _value The amount of token to be burned.
  12. */
  13. function burn(uint256 _value) public {
  14. require(_value > 0);
  15. require(_value <= balances[msg.sender]);
  16. // no need to require value <= totalSupply, since that would imply the
  17. // sender's balance is greater than the totalSupply, which *should* be an assertion failure
  18. address burner = msg.sender;
  19. balances[burner] = balances[burner].sub(_value);
  20. totalSupply = totalSupply.sub(_value);
  21. Burn(burner, _value);
  22. }
  23. }