TokenDestructible.sol 965 B

123456789101112131415161718192021222324252627282930
  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. ///.Base contract that can be destroyed by owner. All funds in contract including
  7. /// listed tokens will be sent to the owner
  8. contract TokenDestructible is Ownable {
  9. /// @notice Terminate contract and refund to owner
  10. /// @param tokens List of addresses of ERC20 or ERC20Basic token contracts to
  11. // refund
  12. /// @notice The called token contracts could try to re-enter this contract.
  13. // Only supply token contracts you
  14. function destroy(address[] tokens) onlyOwner {
  15. // Transfer tokens to owner
  16. for(uint i = 0; i < tokens.length; i++) {
  17. ERC20Basic token = ERC20Basic(tokens[i]);
  18. uint256 balance = token.balanceOf(this);
  19. token.transfer(owner, balance);
  20. }
  21. // Transfer Eth to owner and terminate contract
  22. selfdestruct(owner);
  23. }
  24. }