Wrong transfer token in Crowdsale contract

Hi everybody:

In a crowdsale contract, it has been deployed with a test token instead of the correct mainnet token. To make matters worse, they have sent a number of mainnet tokens that have been trapped because the interface does not match.

My attempts to solve it have been to inherit the contract in one with the appropriate interface to try to get the tokens.

interface TokenInterface {

    function decimals() external view  returns(uint8);
    function balanceOf(address _address) external view returns(uint256);
    function transfer(address _to, uint256 _value) external returns (bool success);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

contract Rescate is Ownable { 

  TokenInterface TokenContract; 
  address public token;
  address public addressCrowsale;

            constructor  (address _token, address _addressCrowsale
            )  public {
                            TokenContract = TokenInterface(_token);  
                            token = _token;
                            addressCrowsale = _addressCrowsale;

              function withDraw() public  onlyOwner() {
                uint256 rest = TokenContract.balanceOf(addressCrowsale);
                require(TokenContract.transferFrom(addressCrowsale, owner(), rest));

              function balance() public  onlyOwner() view returns(uint256){
                return TokenContract.balanceOf(addressCrowsale);



But the transfer form is not possible because for this he would have to get the crowdsale contract to allow the transfer since he is the owner of the tokens.

I think it is not possible then to get those tokens. Even so, I create this post just in case there was any possibility that I did not know

Hello @Cainuriel

I'd have to see the crowdsale contract to be 100% positive. But if its not upgradeable, it support only one token address (set to the testnet one) and receive other tokens (the live mainnet tokens) ... then there is likely no way for you to ever recover them.

Yes, it is impossible. Since the presale contract is a mainnet token holder. And therefore, it would have to be him who approves the movement of the tokens to another account, but of course, he is not a user. And it can't use this function:


    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;

If I use this function in the ransom contract interface, I won't get the msg.sender to be the contract that has the trapped tokens.
Or at least I don't know how to do it.

That is the only solution I see. That the crowsale contract approves the sending of the tokens to the redemption contract(Rescate).

Since the transferfrom function needs that delegation to do the transfer.