BurnableToken.sol 811 B

123456789101112131415161718192021222324252627
  1. pragma solidity ^0.4.18;
  2. import './BasicToken.sol';
  3. /**
  4. * @title Burnable Token
  5. * @dev Token that can be irreversibly burned (destroyed).
  6. */
  7. contract BurnableToken is BasicToken {
  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 <= balances[msg.sender]);
  15. // no need to require value <= totalSupply, since that would imply the
  16. // sender's balance is greater than the totalSupply, which *should* be an assertion failure
  17. address burner = msg.sender;
  18. balances[burner] = balances[burner].sub(_value);
  19. totalSupply = totalSupply.sub(_value);
  20. Burn(burner, _value);
  21. }
  22. }