Late 2018 custody address that anyone may empty, provided the money goes to its owner: one function moves ether or any ERC20, with the wallet's own address standing in for ether.
Historical Significance
Most deposit addresses of this period solve the collection problem by giving the sweeper the keys. This one inverts it. By making the destination, not the caller, the thing that is authorised, the wallet turns sweeping into a permissionless operation that cannot be misdirected. The private key stays offline and the sweeping infrastructure becomes disposable.
The other idea in here is the sentinel. Treating the contract's own address as the name for ether gives a single function signature that covers both asset kinds, years before the practice of using the zero address for the same purpose settled into convention. It is a small piece of interface design, made by someone who had to operate several hundred of these and did not want two code paths to reason about.
Token Information
Key Facts
Description
The interface is borrowed from ERC20 and used for something else. transferFrom takes a token, a destination and an amount, and balanceOf takes a token, but the token argument is a selector rather than a subject: pass the wallet's own address and it means ether, pass anything else and it means that contract's balance held here. One code path, two asset kinds, no separate withdrawEther.
The access rule is the part worth reading twice. A caller is allowed through if it is the owner, or if the destination is the owner. Anyone at all can therefore push the wallet's contents home, and only the owner can send them anywhere else. That is deliberate: it lets an operator run an automated collector that holds no private key of any consequence, because the worst a compromised collector can do is move money to the address it was already going to.
Ether leaves through send wrapped in a require rather than transfer, which keeps the 2300 gas stipend and produces a plain revert instead of bubbling the callee's error. The ERC20 interface it compiles against declares transfer as returning nothing, so the token's return value is never examined, only the success of the call. Each move logs a Transfer event with the token and destination indexed, reusing the ERC20 topic for an outbound sweep.
Source Verified
Byzantium Era
First Metropolis hard fork. Added zk-SNARK precompiles, REVERT opcode, and staticcall.
Bytecode Overview
Verified Source Available
This contract has verified source code.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
pragma solidity ^0.4.24;
contract ERC20Basic {
function transfer(address to, uint256 value) public;
function balanceOf(address who) public view returns (uint256);
}
contract SweepableWallet {
address public owner;
event Transfer(address indexed token, address indexed to, uint256 value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
function transferFrom(address _token, address _to, uint256 _amount) public returns (bool) {
require(msg.sender == owner || _to == owner);
require(balanceOf(_token) >= _amount);
if (address(this) == _token) {
require(_to.send(_amount));
} else {
ERC20Basic(_token).transfer(_to, _amount);
}
emit Transfer(_token, _to, _amount);
return true;
}
function balanceOf(address _token) public view returns (uint256) {
if (address(this) == _token) {
return _token.balance;
}
return ERC20Basic(_token).balanceOf(address(this));
}
function transferOwnership(address _newOwner) public {
require(msg.sender == owner);
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
function () public payable {
}
}External Links
Related contracts
SweepableWallet
Same deployerLate 2018 custody address that anyone may empty, provided the money goes to its owner: one function moves ether or any ERC20, with the wallet's own address standing in for ether.
0x6ec42c...7a2b1dSeptember 13, 2018SweepableWallet
Same deployerLate 2018 custody address that anyone may empty, provided the money goes to its owner: one function moves ether or any ERC20, with the wallet's own address standing in for ether.
0x5d8abb...0902a8September 13, 2018SweepableWallet
Same deployerLate 2018 custody address that anyone may empty, provided the money goes to its owner: one function moves ether or any ERC20, with the wallet's own address standing in for ether.
0xa8a2ad...7ee002September 13, 2018SweepableWallet
Same deployerLate 2018 custody address that anyone may empty, provided the money goes to its owner: one function moves ether or any ERC20, with the wallet's own address standing in for ether.
0x746277...1f7c61September 13, 2018SweepableWallet
Same deployerLate 2018 custody address that anyone may empty, provided the money goes to its owner: one function moves ether or any ERC20, with the wallet's own address standing in for ether.
0x78277e...ee51b2September 13, 2018SweepableWallet
Same deployerLate 2018 custody address that anyone may empty, provided the money goes to its owner: one function moves ether or any ERC20, with the wallet's own address standing in for ether.
0x7b5ef3...27ff68September 13, 2018