Verified contractPartialMIT
RecoverTokens
Address0x617b8808292bf241b97ded599bb11bcb746eb8b7
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- No
- EVM version
- cancun
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 21,468,527
- Creation transaction
- 0x3d72515fb2…e9dde62b70
RecoverTokens.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
}
contract RecoverTokens {
address public owner;
address public constant previousSDCP = 0x2A63cF75dD704F638BD67ABe3FB5941aE0BCb8D9; // 原 SDCP 合约地址
address public constant usdtToken = 0xdAC17F958D2ee523a2206206994597C13D831ec7; // USDT 合约地址
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not the contract owner");
_;
}
// 查询 SDCP 合约中 USDT 的余额
function checkUSDTBalance() public view returns (uint256) {
IERC20 usdt = IERC20(usdtToken);
return usdt.balanceOf(previousSDCP);
}
// 尝试直接从 SDCP 合约转出 USDT
function recoverUSDTDirect(address recipient, uint256 amount) public onlyOwner {
IERC20 usdt = IERC20(usdtToken);
require(usdt.transfer(recipient, amount), "Direct transfer failed");
}
// 尝试通过 transferFrom 从 SDCP 合约转出 USDT
function recoverUSDTViaTransferFrom(address recipient, uint256 amount) public onlyOwner {
IERC20 usdt = IERC20(usdtToken);
require(usdt.transferFrom(previousSDCP, recipient, amount), "TransferFrom failed");
}
// 尝试通过 approve 和 transferFrom 组合从 SDCP 合约转出 USDT
function recoverUSDTViaApproveAndTransfer(address spender, uint256 amount) public onlyOwner {
IERC20 usdt = IERC20(usdtToken);
require(usdt.approve(spender, amount), "Approval failed");
require(usdt.transferFrom(previousSDCP, spender, amount), "Approve and TransferFrom failed");
}
// 分批提取 SDCP 合约中的 USDT(逐步恢复余额)
function recoverUSDTInChunks(address recipient, uint256 chunkSize) public onlyOwner {
IERC20 usdt = IERC20(usdtToken);
uint256 balance = usdt.balanceOf(previousSDCP);
require(balance > 0, "No tokens to recover");
uint256 remaining = balance;
while (remaining > 0) {
uint256 toTransfer = remaining >= chunkSize ? chunkSize : remaining;
require(usdt.transfer(recipient, toTransfer), "Chunk transfer failed");
remaining -= toTransfer;
}
}
// 迁移 ownership
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "New owner is the zero address");
owner = newOwner;
}
}Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "cancun",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.