HasNoTokens.sol 1.0 KB

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