TokenDestructible.sol 1.0 KB

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