HasNoTokens.sol 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. pragma solidity ^0.4.11;
  2. import "./Ownable.sol";
  3. import "../token/ERC20Basic.sol";
  4. /**
  5. * @title Contracts that should not own Tokens
  6. * @author Remco Bloemen <remco@2π.com>
  7. * @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.
  8. * Should tokens (any ERC20Basic compatible) end up in the contract, it allows the
  9. * owner to reclaim the tokens.
  10. */
  11. contract HasNoTokens is Ownable {
  12. /**
  13. * @dev Reject all ERC23 compatible tokens
  14. * @param from_ address The address that is transferring the tokens
  15. * @param value_ uint256 the amount of the specified token
  16. * @param data_ Bytes The data passed from the caller.
  17. */
  18. function tokenFallback(address from_, uint256 value_, bytes data_) external {
  19. throw;
  20. }
  21. /**
  22. * @dev Reclaim all ERC20Basic compatible tokens
  23. * @param tokenAddr address The address of the token contract
  24. */
  25. function reclaimToken(address tokenAddr) external onlyOwner {
  26. ERC20Basic tokenInst = ERC20Basic(tokenAddr);
  27. uint256 balance = tokenInst.balanceOf(this);
  28. tokenInst.transfer(owner, balance);
  29. }
  30. }