Does a inheritable token sweeping contract exist?


Does anyone know of an existing contract that can be inherited to provide the sweeping up of arbitrary tokens from a contract address to a benefactor address.

A user can use a contract address as the recipient in a token transfer, and unless there's a way for that contract to sign a transfer transaction to move those tokens, they are effectively lost.

Before I head off a create an implementation, is there already a generalised solution / Open Zeppelin contract that solves this problem?

Here is a simple function for recoverring lost tokens in this contract. Anyone can call this function to retrieve tokens to BENEFACTOR, which should have been already hardcoded in this contract. You may create a contract with it to serve your purpose.

    function recoverLostToken(address token) external returns (bool) {
        IERC20(token).safeTransfer(BENEFACTOR, IERC20(token).balanceOf(address(this)));
        return true;
1 Like