TokenDestructible.sol 943 B

1234567891011121314151617181920212223242526272829303132
  1. pragma solidity ^0.4.8;
  2. import "../ownership/Ownable.sol";
  3. import "../token/ERC20Basic.sol";
  4. /** @title TokenDestructible:
  5. * @author Remco Bloemen <remco@2π.com>
  6. * @dev Base contract that can be destroyed by owner. All funds in contract including
  7. * listed tokens will be sent to the owner
  8. */
  9. contract TokenDestructible is Ownable {
  10. /** @notice Terminate contract and refund to owner
  11. * @param tokens List of addresses of ERC20 or ERC20Basic token contracts to
  12. refund
  13. * @notice The called token contracts could try to re-enter this contract.Only
  14. supply token contracts you
  15. */
  16. function destroy(address[] tokens) onlyOwner {
  17. // Transfer tokens to owner
  18. for(uint i = 0; i < tokens.length; i++) {
  19. ERC20Basic token = ERC20Basic(tokens[i]);
  20. uint256 balance = token.balanceOf(this);
  21. token.transfer(owner, balance);
  22. }
  23. // Transfer Eth to owner and terminate contract
  24. selfdestruct(owner);
  25. }
  26. }