BurnableToken.sol 814 B

1234567891011121314151617181920212223242526272829
  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. Transfer(burner, address(0), _value);
  22. }
  23. }