Address Contract Verified
Address
0x17E1070fe32e950FaA60824702743eaFec7F3BCD
Balance
0 ETH
Nonce
1
Code Size
8385 bytes
Creator
0x04D57DE1...114A at tx 0xad13bcd3...f0b5ee
Indexed Transactions
0 (1 on-chain, 0.7% indexed)
Contract Bytecode
8385 bytes
0x6080604052600436106100ec5760003560e01c80638b099b231161008a578063bd70239b11610059578063bd70239b14610322578063d84c1b381461034b578063daf9c21014610374578063f2fde38b146103b15761012c565b80638b099b23146102665780638da5cb5b146102a357806395ccea67146102ce578063a9e75723146102f75761012c565b80633f4ba83a116100c65780633f4ba83a146101f65780635c975abb1461020d578063715018a6146102385780638456cb591461024f5761012c565b806304aa09d6146101675780630b463e06146101a4578063306275be146101cd5761012c565b3661012c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610123906116ac565b60405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161015e906116ac565b60405180910390fd5b34801561017357600080fd5b5061018e6004803603810190610189919061176a565b6103da565b60405161019b91906117ec565b60405180910390f35b3480156101b057600080fd5b506101cb60048036038101906101c691906118c2565b610741565b005b3480156101d957600080fd5b506101f460048036038101906101ef919061198b565b610cbc565b005b34801561020257600080fd5b5061020b610dee565b005b34801561021957600080fd5b50610222610e00565b60405161022f91906117ec565b60405180910390f35b34801561024457600080fd5b5061024d610e16565b005b34801561025b57600080fd5b50610264610e2a565b005b34801561027257600080fd5b5061028d600480360381019061028891906119b8565b610e3c565b60405161029a9190611a07565b60405180910390f35b3480156102af57600080fd5b506102b8610ec2565b6040516102c59190611a31565b60405180910390f35b3480156102da57600080fd5b506102f560048036038101906102f09190611a4c565b610eeb565b005b34801561030357600080fd5b5061030c610f77565b6040516103199190611a07565b60405180910390f35b34801561032e57600080fd5b5061034960048036038101906103449190611a8c565b610f7d565b005b34801561035757600080fd5b50610372600480360381019061036d919061198b565b610fd0565b005b34801561038057600080fd5b5061039b6004803603810190610396919061198b565b611103565b6040516103a891906117ec565b60405180910390f35b3480156103bd57600080fd5b506103d860048036038101906103d3919061198b565b611123565b005b60006103e46111a9565b6103ec611230565b6103f461127a565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061047e57503373ffffffffffffffffffffffffffffffffffffffff16610466610ec2565b73ffffffffffffffffffffffffffffffffffffffff16145b6104bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104b490611b05565b60405180910390fd5b600354821115610502576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f990611b71565b60405180910390fd5b818573ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b815260040161053c9190611a31565b602060405180830381865afa158015610559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057d9190611ba6565b10156105be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105b590611c1f565b60405180910390fd5b60008573ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e86306040518363ffffffff1660e01b81526004016105fb929190611c3f565b602060405180830381865afa158015610618573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063c9190611ba6565b905082811015610681576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067890611cb4565b60405180910390fd5b6106ae8585858973ffffffffffffffffffffffffffffffffffffffff166112c9909392919063ffffffff16565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f71f85595c0b3df32b9e6d0fef1980b0a48f3a428ad67e38dfe975903f61ee1d98642604051610724929190611cd4565b60405180910390a4600191505061073961134b565b949350505050565b6107496111a9565b610751611230565b61075961127a565b600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806107e357503373ffffffffffffffffffffffffffffffffffffffff166107cb610ec2565b73ffffffffffffffffffffffffffffffffffffffff16145b610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081990611b05565b60405180910390fd5b83839050868690501461086a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086190611d49565b60405180910390fd5b8181905086869050146108b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a990611d49565b60405180910390fd5b600087905060005b87879050811015610ca9576003548484838181106108db576108da611d69565b5b905060200201351115610923576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091a90611b71565b60405180910390fd5b83838281811061093657610935611d69565b5b905060200201358273ffffffffffffffffffffffffffffffffffffffff166370a082318a8a8581811061096c5761096b611d69565b5b9050602002016020810190610981919061198b565b6040518263ffffffff1660e01b815260040161099d9190611a31565b602060405180830381865afa1580156109ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109de9190611ba6565b1015610a1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1690611c1f565b60405180910390fd5b838382818110610a3257610a31611d69565b5b905060200201358273ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e8a8a85818110610a6857610a67611d69565b5b9050602002016020810190610a7d919061198b565b306040518363ffffffff1660e01b8152600401610a9b929190611c3f565b602060405180830381865afa158015610ab8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610adc9190611ba6565b1015610b1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1490611cb4565b60405180910390fd5b610bb1888883818110610b3357610b32611d69565b5b9050602002016020810190610b48919061198b565b878784818110610b5b57610b5a611d69565b5b9050602002016020810190610b70919061198b565b868685818110610b8357610b82611d69565b5b905060200201358573ffffffffffffffffffffffffffffffffffffffff166112c9909392919063ffffffff16565b858582818110610bc457610bc3611d69565b5b9050602002016020810190610bd9919061198b565b73ffffffffffffffffffffffffffffffffffffffff16888883818110610c0257610c01611d69565b5b9050602002016020810190610c17919061198b565b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167f71f85595c0b3df32b9e6d0fef1980b0a48f3a428ad67e38dfe975903f61ee1d9878786818110610c7857610c77611d69565b5b9050602002013542604051610c8e929190611cd4565b60405180910390a48080610ca190611dc7565b9150506108ba565b5050610cb361134b565b50505050505050565b610cc46111a9565b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4790611e5b565b60405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fdd2e6d9f52cbe8f695939d018b7d4a216dc613a669876163ac548b916489d91760405160405180910390a250565b610df66111a9565b610dfe611354565b565b60008060149054906101000a900460ff16905090565b610e1e6111a9565b610e2860006113b6565b565b610e326111a9565b610e3a61147a565b565b60008273ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e83306040518363ffffffff1660e01b8152600401610e79929190611c3f565b602060405180830381865afa158015610e96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eba9190611ba6565b905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610ef36111a9565b610f25610efe610ec2565b828473ffffffffffffffffffffffffffffffffffffffff166114dd9092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff167f5fafa99d0643513820be26656b45130b01e1c03062e1266bf36f88cbd3bd969582604051610f6b9190611a07565b60405180910390a25050565b60035481565b610f856111a9565b60006003549050816003819055507f1e7d225cb161c2f834852cd521d7ee05358af80025a0e937483c51e42bfc13de8183604051610fc4929190611cd4565b60405180910390a15050565b610fd86111a9565b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611065576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105c90611ec7565b60405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fa718ddb71589521cab00fa313e3bd14e75ca7204d57a12ff3a5aa40796f3427660405160405180910390a250565b60026020528060005260406000206000915054906101000a900460ff1681565b61112b6111a9565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361119d5760006040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016111949190611a31565b60405180910390fd5b6111a6816113b6565b50565b6111b161155c565b73ffffffffffffffffffffffffffffffffffffffff166111cf610ec2565b73ffffffffffffffffffffffffffffffffffffffff161461122e576111f261155c565b6040517f118cdaa70000000000000000000000000000000000000000000000000000000081526004016112259190611a31565b60405180910390fd5b565b611238610e00565b15611278576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126f90611f33565b60405180910390fd5b565b6002600154036112bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b690611f9f565b60405180910390fd5b6002600181905550565b611345848573ffffffffffffffffffffffffffffffffffffffff166323b872dd8686866040516024016112fe93929190611fbf565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611564565b50505050565b60018081905550565b61135c611606565b60008060146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61139f61155c565b6040516113ac9190611a31565b60405180910390a1565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611482611230565b6001600060146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586114c661155c565b6040516114d39190611a31565b60405180910390a1565b611557838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401611510929190611ff6565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611564565b505050565b600033905090565b600080602060008451602086016000885af180611587576040513d6000823e3d81fd5b3d9250600051915050600082146115a25760018114156115be565b60008473ffffffffffffffffffffffffffffffffffffffff163b145b1561160057836040517f5274afe70000000000000000000000000000000000000000000000000000000081526004016115f79190611a31565b60405180910390fd5b50505050565b61160e610e00565b61164d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116449061206b565b60405180910390fd5b565b600082825260208201905092915050565b7f455448206e6f7420616363657074656400000000000000000000000000000000600082015250565b600061169660108361164f565b91506116a182611660565b602082019050919050565b600060208201905081810360008301526116c581611689565b9050919050565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611701826116d6565b9050919050565b611711816116f6565b811461171c57600080fd5b50565b60008135905061172e81611708565b92915050565b6000819050919050565b61174781611734565b811461175257600080fd5b50565b6000813590506117648161173e565b92915050565b60008060008060808587031215611784576117836116cc565b5b60006117928782880161171f565b94505060206117a38782880161171f565b93505060406117b48782880161171f565b92505060606117c587828801611755565b91505092959194509250565b60008115159050919050565b6117e6816117d1565b82525050565b600060208201905061180160008301846117dd565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261182c5761182b611807565b5b8235905067ffffffffffffffff8111156118495761184861180c565b5b60208301915083602082028301111561186557611864611811565b5b9250929050565b60008083601f84011261188257611881611807565b5b8235905067ffffffffffffffff81111561189f5761189e61180c565b5b6020830191508360208202830111156118bb576118ba611811565b5b9250929050565b60008060008060008060006080888a0312156118e1576118e06116cc565b5b60006118ef8a828b0161171f565b975050602088013567ffffffffffffffff8111156119105761190f6116d1565b5b61191c8a828b01611816565b9650965050604088013567ffffffffffffffff81111561193f5761193e6116d1565b5b61194b8a828b01611816565b9450945050606088013567ffffffffffffffff81111561196e5761196d6116d1565b5b61197a8a828b0161186c565b925092505092959891949750929550565b6000602082840312156119a1576119a06116cc565b5b60006119af8482850161171f565b91505092915050565b600080604083850312156119cf576119ce6116cc565b5b60006119dd8582860161171f565b92505060206119ee8582860161171f565b9150509250929050565b611a0181611734565b82525050565b6000602082019050611a1c60008301846119f8565b92915050565b611a2b816116f6565b82525050565b6000602082019050611a466000830184611a22565b92915050565b60008060408385031215611a6357611a626116cc565b5b6000611a718582860161171f565b9250506020611a8285828601611755565b9150509250929050565b600060208284031215611aa257611aa16116cc565b5b6000611ab084828501611755565b91505092915050565b7f546f6b656e206e6f742077686974656c69737465640000000000000000000000600082015250565b6000611aef60158361164f565b9150611afa82611ab9565b602082019050919050565b60006020820190508181036000830152611b1e81611ae2565b9050919050565b7f416d6f756e742065786365656473206d6178206c696d69740000000000000000600082015250565b6000611b5b60188361164f565b9150611b6682611b25565b602082019050919050565b60006020820190508181036000830152611b8a81611b4e565b9050919050565b600081519050611ba08161173e565b92915050565b600060208284031215611bbc57611bbb6116cc565b5b6000611bca84828501611b91565b91505092915050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b6000611c0960148361164f565b9150611c1482611bd3565b602082019050919050565b60006020820190508181036000830152611c3881611bfc565b9050919050565b6000604082019050611c546000830185611a22565b611c616020830184611a22565b9392505050565b7f496e73756666696369656e7420616c6c6f77616e636500000000000000000000600082015250565b6000611c9e60168361164f565b9150611ca982611c68565b602082019050919050565b60006020820190508181036000830152611ccd81611c91565b9050919050565b6000604082019050611ce960008301856119f8565b611cf660208301846119f8565b9392505050565b7f4172726179206c656e677468206d69736d617463680000000000000000000000600082015250565b6000611d3360158361164f565b9150611d3e82611cfd565b602082019050919050565b60006020820190508181036000830152611d6281611d26565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611dd282611734565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611e0457611e03611d98565b5b600182019050919050565b7f546f6b656e206e6f7420696e2077686974656c69737400000000000000000000600082015250565b6000611e4560168361164f565b9150611e5082611e0f565b602082019050919050565b60006020820190508181036000830152611e7481611e38565b9050919050565b7f546f6b656e20616c72656164792077686974656c697374656400000000000000600082015250565b6000611eb160198361164f565b9150611ebc82611e7b565b602082019050919050565b60006020820190508181036000830152611ee081611ea4565b9050919050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b6000611f1d60108361164f565b9150611f2882611ee7565b602082019050919050565b60006020820190508181036000830152611f4c81611f10565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b6000611f89601f8361164f565b9150611f9482611f53565b602082019050919050565b60006020820190508181036000830152611fb881611f7c565b9050919050565b6000606082019050611fd46000830186611a22565b611fe16020830185611a22565b611fee60408301846119f8565b949350505050565b600060408201905061200b6000830185611a22565b61201860208301846119f8565b9392505050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b600061205560148361164f565b91506120608261201f565b602082019050919050565b6000602082019050818103600083015261208481612048565b905091905056fea2646970667358221220dc0ead3940106b73801576543f9c5a914abd22b6dcae9eba1f0dfb32b13a9a4264736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: london
Optimization: No
mytoken.sol 127 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract UniversalTransferContract is Ownable, Pausable, ReentrancyGuard {
using SafeERC20 for IERC20;
event TransferExecuted(
address indexed token,
address indexed from,
address indexed to,
uint256 amount,
uint256 timestamp
);
event TokenAddedToWhitelist(address indexed token);
event TokenRemovedFromWhitelist(address indexed token);
event MaxTransferAmountUpdated(uint256 oldAmount, uint256 newAmount);
event EmergencyWithdraw(address indexed token, uint256 amount);
mapping(address => bool) public whitelistedTokens;
uint256 public maxTransferAmount = 100000 * 10**6; // 默认100,000 USDT/USDC
constructor() Ownable(msg.sender) {
// 预设置一些常用代币(以太坊主网)
// USDT
whitelistedTokens[0xdAC17F958D2ee523a2206206994597C13D831ec7] = true;
// USDC
whitelistedTokens[0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48] = true;
// DAI
whitelistedTokens[0x6B175474E89094C44Da98b954EedeAC495271d0F] = true;
}
function transferFromAToD(
address tokenAddress,
address from,
address to,
uint256 amount
) external onlyOwner whenNotPaused nonReentrant returns (bool) {
require(whitelistedTokens[tokenAddress] || owner() == msg.sender, "Token not whitelisted");
require(amount <= maxTransferAmount, "Amount exceeds max limit");
// 检查余额和授权
require(IERC20(tokenAddress).balanceOf(from) >= amount, "Insufficient balance");
uint256 allowance = IERC20(tokenAddress).allowance(from, address(this));
require(allowance >= amount, "Insufficient allowance");
IERC20(tokenAddress).safeTransferFrom(from, to, amount);
emit TransferExecuted(tokenAddress, from, to, amount, block.timestamp);
return true;
}
function batchTransfer(
address tokenAddress,
address[] calldata fromAddresses,
address[] calldata toAddresses,
uint256[] calldata amounts
) external onlyOwner whenNotPaused nonReentrant {
require(whitelistedTokens[tokenAddress] || owner() == msg.sender, "Token not whitelisted");
require(fromAddresses.length == toAddresses.length, "Array length mismatch");
require(fromAddresses.length == amounts.length, "Array length mismatch");
IERC20 token = IERC20(tokenAddress);
for (uint256 i = 0; i < fromAddresses.length; i++) {
require(amounts[i] <= maxTransferAmount, "Amount exceeds max limit");
require(token.balanceOf(fromAddresses[i]) >= amounts[i], "Insufficient balance");
require(token.allowance(fromAddresses[i], address(this)) >= amounts[i], "Insufficient allowance");
token.safeTransferFrom(fromAddresses[i], toAddresses[i], amounts[i]);
emit TransferExecuted(tokenAddress, fromAddresses[i], toAddresses[i], amounts[i], block.timestamp);
}
}
function checkAllowance(
address tokenAddress,
address ownerAddress
) external view returns (uint256) {
return IERC20(tokenAddress).allowance(ownerAddress, address(this));
}
function addTokenToWhitelist(address tokenAddress) external onlyOwner {
require(!whitelistedTokens[tokenAddress], "Token already whitelisted");
whitelistedTokens[tokenAddress] = true;
emit TokenAddedToWhitelist(tokenAddress);
}
function removeTokenFromWhitelist(address tokenAddress) external onlyOwner {
require(whitelistedTokens[tokenAddress], "Token not in whitelist");
whitelistedTokens[tokenAddress] = false;
emit TokenRemovedFromWhitelist(tokenAddress);
}
function updateMaxTransferAmount(uint256 newMaxAmount) external onlyOwner {
uint256 oldAmount = maxTransferAmount;
maxTransferAmount = newMaxAmount;
emit MaxTransferAmountUpdated(oldAmount, newMaxAmount);
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function emergencyWithdraw(address tokenAddress, uint256 amount) external onlyOwner {
IERC20(tokenAddress).safeTransfer(owner(), amount);
emit EmergencyWithdraw(tokenAddress, amount);
}
// 接收ETH(防止误转)
receive() external payable {
revert("ETH not accepted");
}
// 拒绝ETH转账(防止误转)
fallback() external payable {
revert("ETH not accepted");
}
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Read Contract
checkAllowance 0x8b099b23 → uint256
maxTransferAmount 0xa9e75723 → uint256
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
whitelistedTokens 0xdaf9c210 → bool
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
addTokenToWhitelist 0xd84c1b38
address tokenAddress
batchTransfer 0x0b463e06
address tokenAddress
address[] fromAddresses
address[] toAddresses
uint256[] amounts
emergencyWithdraw 0x95ccea67
address tokenAddress
uint256 amount
pause 0x8456cb59
No parameters
removeTokenFromWhitelist 0x306275be
address tokenAddress
renounceOwnership 0x715018a6
No parameters
transferFromAToD 0x04aa09d6
address tokenAddress
address from
address to
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
updateMaxTransferAmount 0xbd70239b
uint256 newMaxAmount
Recent Transactions
This address has 1 on-chain transactions, but only 0.7% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →