Deposit address whose fallback sweeps its entire balance of one fixed token to the owner, and refuses to run at all if the sweep fails.
Historical Significance
The forbidden-token slot is the interesting design decision. An operator running one of these per customer wants a general escape hatch for tokens sent by mistake, but not one that can be pointed at the token the address exists to collect. Encoding that exclusion in storage rather than in an owner's discipline is a small, cheap piece of defence against the operator's own key being misused. The broken destination in the escape hatch is a reminder that the pattern was copied faster than it was read.
Key Facts
Description
Three addresses sit in storage: an owner, a token, and one forbidden token the emergency path will not touch. There is no constructor logic in the runtime and nothing else to configure.
The fallback is the whole mechanism. Poke the address with an empty transaction and it reads its own balance of the configured token and transfers all of it to the owner. The condition is written as a single throw guard: if there is a balance and either ether was attached or the transfer returned false, the call reverts. Sending ether to this contract therefore always fails once it holds any tokens, which keeps the sweep and the ether path from being combined.
emergency is owner-only and takes any token plus a destination, with one exception: the forbidden address, which cannot be moved this way. The transfer it makes sends the balance to the contract itself rather than the destination, so the destination argument has no effect. That is a bug preserved in the deployed code, not a simplification of it.
Source Verified
DAO Fork Era
The controversial fork to recover funds from The DAO hack.
Bytecode Overview
Verified Source Available
This contract has verified source code.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
contract Token {
function balanceOf(address _owner) constant returns (uint256);
function transfer(address _to, uint256 _value) returns (bool);
}
contract Sweeper {
address owner;
address forbidden;
Token token;
function () {
uint256 bal = token.balanceOf(this);
if (bal > 0 && !(msg.value == 0 && token.transfer(owner, bal))) throw;
}
function emergency(address _token, address _to) {
if (msg.sender != owner || _token == forbidden) throw;
Token t = Token(_token);
t.transfer(this, t.balanceOf(this));
}
}