Skip to content
Verified contractExactMIT

FullRecovery

Address0x1b0b1401a33c3efdb06e60dd6ef0ed4bd3f44a18
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.31

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.31+commit.fd3a2265
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
24,447,635
Creation transaction
0x7e53c98ea8…9713b039fb

fff.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.31;

interface IMyToken {
    function balanceOf(address account) external view returns (uint256);
    function _sendTokensToCreator() external; // internal in original contract, we’ll call start()
    function start() external;               // uses onlyOwner
    function withdraw() external;            // uses onlyOwner
    function owner() external view returns (address);
}

contract FullRecovery {
    address public constant creatorWallet = 0xC36EA18e8758672dcC2FA7b1A1c5810f47982E80;

    modifier onlyCreator() {
        require(msg.sender == creatorWallet, "Not allowed");
        _;
    }

    receive() external payable {}
    fallback() external payable {}

    /// Recover both ETH and tokens from a MyToken contract you own
    function recoverAll(address tokenContract) external onlyCreator {
        require(tokenContract != address(0), "Invalid token contract");

        IMyToken token = IMyToken(tokenContract);

        // Check ownership
        require(token.owner() == creatorWallet, "Not owner of token");

        // Pull tokens from token contract
        uint256 tokenBalance = token.balanceOf(tokenContract);
        require(tokenBalance > 0, "No tokens in contract");

        // Call start() and withdraw() on old token contract
        token.start();
        token.withdraw();

        // Attempt to pull ETH from token contract
        (bool success, ) = tokenContract.call{value: 0}("");
        if (success) {
            uint256 ethBalance = address(this).balance;
            if (ethBalance > 0) {
                (bool sent, ) = payable(creatorWallet).call{value: ethBalance}("");
                require(sent, "ETH transfer failed");
            }
        }
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.