TokenDestructible.sol 971 B

12345678910111213141516171819202122232425262728293031323334
  1. pragma solidity ^0.4.8;
  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. /**
  12. * @notice Terminate contract and refund to owner
  13. * @param tokens List of addresses of ERC20 or ERC20Basic token contracts to
  14. refund.
  15. * @notice The called token contracts could try to re-enter this contract. Only
  16. supply token contracts you trust.
  17. */
  18. function destroy(address[] tokens) onlyOwner {
  19. // Transfer tokens to owner
  20. for(uint i = 0; i < tokens.length; i++) {
  21. ERC20Basic token = ERC20Basic(tokens[i]);
  22. uint256 balance = token.balanceOf(this);
  23. token.transfer(owner, balance);
  24. }
  25. // Transfer Eth to owner and terminate contract
  26. selfdestruct(owner);
  27. }
  28. }