Contract

0xfd51a76313cb0eC8d5068c62DC5Fe62C6d3Ae528

Overview
0.0000 Trust Bitcoin
$0.0000
More Info
 
Contract Source Code (Solidity Standard Json-Input format)

File 1 of 1 : USDTAirdrop.sol

// SPDX-License-Identifier: MIT pragma solidity 0.8.10; /// @title USDT Airdrop Distribution Contract /// @notice This contract allows the owner to airdrop USDT tokens to multiple users in chunks /// @dev Uses nonReentrant modifier to prevent reentrancy attacks interface IERC20 { /// @notice Transfers tokens from the contract to a recipient /// @param recipient Address to receive the tokens /// @param amount Number of tokens to transfer /// @return success True if the transfer succeeds function transfer(address recipient, uint256 amount) external returns (bool); /// @notice Returns the balance of a given account /// @param account Address to query the balance of /// @return balance The number of tokens owned by the account function balanceOf(address account) external view returns (uint256); } contract USDTAirdrop { /// @notice Address of the contract owner address public owner; /// @notice The USDT token to be distributed IERC20 public USDT; /// @notice Mapping to store each recipient's airdrop amount mapping(address => uint256) public airdropAmounts; /// @notice Array of recipient addresses address[] public recipients; /// @notice Total USDT allocated for airdrop uint256 public airdropAmount; /// @notice Number of users processed per chunk uint256 public chunkSize; /// @notice Last index processed during chunk distribution uint256 public lastDistributedIndex; /// @dev Modifier to restrict function access to contract owner modifier onlyOwner() { require(msg.sender == owner, "Only owner can call this function"); _; } uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status = _NOT_ENTERED; /// @dev Modifier to prevent reentrant calls modifier nonReentrant() { require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); _status = _ENTERED; _; _status = _NOT_ENTERED; } /// @notice Emitted when users are added to the airdrop list event UsersAdded(uint256 count, uint256 totalAmount); /// @notice Emitted when tokens are distributed to a recipient event TokensDistributed(address indexed recipient, uint256 amount); /// @notice Constructor to initialize the airdrop contract /// @param token The address of the USDT token contract constructor(address token) { require(token != address(0), "Invalid USDT address"); owner = msg.sender; USDT = IERC20(token); chunkSize = 100; } /// @notice Adds users and their airdrop amounts /// @param users Array of recipient addresses /// @param amounts Array of corresponding USDT amounts function addUser(address[] calldata users, uint256[] calldata amounts) external onlyOwner nonReentrant { require(users.length == amounts.length, "Arrays length mismatch"); require(users.length > 0, "Empty arrays"); uint256 newTotal; for (uint256 i = 0; i < users.length; i++) { address user = users[i]; uint256 amount = amounts[i]; require(user != address(0), "Invalid address"); require(amount > 0, "Amount must be greater than 0"); recipients.push(user); airdropAmounts[user] = amount; newTotal += amount; } airdropAmount += newTotal; emit UsersAdded(users.length, newTotal); } /// @notice Updates the chunk size for batch distribution /// @param size New chunk size function setChunkSize(uint256 size) external onlyOwner { require(size > 0, "Chunk size must be greater than 0"); chunkSize = size; } /// @notice Distributes tokens to recipients in a batch (chunk) /// @dev Uses `lastDistributedIndex` to track progress function distributeChunk() external onlyOwner nonReentrant { require(lastDistributedIndex < recipients.length, "Airdrop completed"); uint256 endIndex = lastDistributedIndex + chunkSize; if (endIndex > recipients.length) { endIndex = recipients.length; } for (uint256 i = lastDistributedIndex; i < endIndex; i++) { address recipient = recipients[i]; uint256 amount = airdropAmounts[recipient]; if (amount > 0) { airdropAmounts[recipient] = 0; airdropAmount -= amount; bool sent = USDT.transfer(recipient, amount); require(sent, "USDT transfer failed"); emit TokensDistributed(recipient, amount); } } lastDistributedIndex = endIndex; } /// @notice Returns the number of recipients yet to receive their airdrop /// @return count Number of users remaining function getRemainingCount() public view returns (uint256) { return recipients.length - lastDistributedIndex; } /// @notice Allows the owner to withdraw remaining undistributed USDT tokens function withdrawRemaining() external onlyOwner nonReentrant { uint256 balance = USDT.balanceOf(address(this)); bool sent = USDT.transfer(owner, balance); require(sent, "Failed to withdraw remaining tokens"); } /// @notice Transfers contract ownership to a new address /// @param newOwner Address of the new owner function transferOwnership(address newOwner) external onlyOwner { require(newOwner != address(0), "New owner is the zero address"); owner = newOwner; } /// @notice Resets the airdrop data to allow for a new round function resetAirdrop() external onlyOwner nonReentrant { delete recipients; airdropAmount = 0; lastDistributedIndex = 0; } }
ABI Code (Solidity Standard Json-Input format)

File 1 of 1 : ABI.json

[ { "inputs": [ { "internalType": "address[]", "name": "users", "type": "address[]" }, { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } ], "name": "addUser", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "distributeChunk", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "resetAirdrop", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "size", "type": "uint256" } ], "name": "setChunkSize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "token", "type": "address" } ], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "TokensDistributed", "type": "event" }, { "inputs": [ { "internalType": "address", "name": "newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "count", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "totalAmount", "type": "uint256" } ], "name": "UsersAdded", "type": "event" }, { "inputs": [], "name": "withdrawRemaining", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "airdropAmount", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" } ], "name": "airdropAmounts", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "chunkSize", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getRemainingCount", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "lastDistributedIndex", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "name": "recipients", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "USDT", "outputs": [ { "internalType": "contract IERC20", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" } ]
Contract Creation Code
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063c54e44eb1161008c578063de957cf411610066578063de957cf4146101b2578063ee38db95146101c5578063f2fde38b146101cd578063fc2ea8a5146101e057600080fd5b8063c54e44eb1461016c578063cdc324a91461017f578063d1bc76a11461019f57600080fd5b80637b190eab116100c85780637b190eab146101275780638da5cb5b1461012f578063b1ac8be61461015a578063c4a942cb1461016357600080fd5b80632dd4b9fb146100ef57806347aa476e14610104578063482a28a31461010c575b600080fd5b6101026100fd366004610af2565b6101e9565b005b61010261048e565b6101146104fd565b6040519081526020015b60405180910390f35b610102610514565b600054610142906001600160a01b031681565b6040516001600160a01b03909116815260200161011e565b61011460065481565b61011460055481565b600154610142906001600160a01b031681565b61011461018d366004610b5e565b60026020526000908152604090205481565b6101426101ad366004610b8e565b610775565b6101026101c0366004610b8e565b61079f565b610102610828565b6101026101db366004610b5e565b6109ca565b61011460045481565b6000546001600160a01b0316331461021c5760405162461bcd60e51b815260040161021390610ba7565b60405180910390fd5b6002600754141561023f5760405162461bcd60e51b815260040161021390610be8565b600260075582811461028c5760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b6044820152606401610213565b826102c85760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b6044820152606401610213565b6000805b848110156104315760008686838181106102e8576102e8610c1f565b90506020020160208101906102fd9190610b5e565b9050600085858481811061031357610313610c1f565b60200291909101359150506001600160a01b0382166103665760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610213565b600081116103b65760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610213565b60038054600181019091557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180546001600160a01b0319166001600160a01b038416908117909155600090815260026020526040902081905561041a8185610c4b565b93505050808061042990610c63565b9150506102cc565b5080600460008282546104449190610c4b565b909155505060408051858152602081018390527f531c1eb6a83759c05059c86827c920fd0fbbe4fe7834c9b21bb2d1be6b882825910160405180910390a150506001600755505050565b6000546001600160a01b031633146104b85760405162461bcd60e51b815260040161021390610ba7565b600260075414156104db5760405162461bcd60e51b815260040161021390610be8565b60026007556104ec60036000610a6c565b600060048190556006556001600755565b60065460035460009161050f91610c7e565b905090565b6000546001600160a01b0316331461053e5760405162461bcd60e51b815260040161021390610ba7565b600260075414156105615760405162461bcd60e51b815260040161021390610be8565b6002600755600354600654106105ad5760405162461bcd60e51b8152602060048201526011602482015270105a5c991c9bdc0818dbdb5c1b195d1959607a1b6044820152606401610213565b60006005546006546105bf9190610c4b565b6003549091508111156105d157506003545b6006545b8181101561076a576000600382815481106105f2576105f2610c1f565b60009182526020808320909101546001600160a01b031680835260029091526040909120549091508015610755576001600160a01b03821660009081526002602052604081208190556004805483929061064d908490610c7e565b909155505060015460405163a9059cbb60e01b81526001600160a01b03848116600483015260248201849052600092169063a9059cbb906044016020604051808303816000875af11580156106a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ca9190610c95565b9050806107105760405162461bcd60e51b81526020600482015260146024820152731554d115081d1c985b9cd9995c8819985a5b195960621b6044820152606401610213565b826001600160a01b03167f16b0da2ffcb90c6723317bd637d9aad7f04711f42bbe0ac0918ebe10f1f9001c8360405161074b91815260200190565b60405180910390a2505b5050808061076290610c63565b9150506105d5565b506006556001600755565b6003818154811061078557600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b031633146107c95760405162461bcd60e51b815260040161021390610ba7565b600081116108235760405162461bcd60e51b815260206004820152602160248201527f4368756e6b2073697a65206d7573742062652067726561746572207468616e206044820152600360fc1b6064820152608401610213565b600555565b6000546001600160a01b031633146108525760405162461bcd60e51b815260040161021390610ba7565b600260075414156108755760405162461bcd60e51b815260040161021390610be8565b60026007556001546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156108c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e79190610cb7565b6001546000805460405163a9059cbb60e01b81526001600160a01b03918216600482015260248101859052939450909291169063a9059cbb906044016020604051808303816000875af1158015610942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109669190610c95565b9050806109c15760405162461bcd60e51b815260206004820152602360248201527f4661696c656420746f2077697468647261772072656d61696e696e6720746f6b604482015262656e7360e81b6064820152608401610213565b50506001600755565b6000546001600160a01b031633146109f45760405162461bcd60e51b815260040161021390610ba7565b6001600160a01b038116610a4a5760405162461bcd60e51b815260206004820152601d60248201527f4e6577206f776e657220697320746865207a65726f20616464726573730000006044820152606401610213565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b5080546000825590600052602060002090810190610a8a9190610a8d565b50565b5b80821115610aa25760008155600101610a8e565b5090565b60008083601f840112610ab857600080fd5b50813567ffffffffffffffff811115610ad057600080fd5b6020830191508360208260051b8501011115610aeb57600080fd5b9250929050565b60008060008060408587031215610b0857600080fd5b843567ffffffffffffffff80821115610b2057600080fd5b610b2c88838901610aa6565b90965094506020870135915080821115610b4557600080fd5b50610b5287828801610aa6565b95989497509550505050565b600060208284031215610b7057600080fd5b81356001600160a01b0381168114610b8757600080fd5b9392505050565b600060208284031215610ba057600080fd5b5035919050565b60208082526021908201527f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f6040820152603760f91b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610c5e57610c5e610c35565b500190565b6000600019821415610c7757610c77610c35565b5060010190565b600082821015610c9057610c90610c35565b500390565b600060208284031215610ca757600080fd5b81518015158114610b8757600080fd5b600060208284031215610cc957600080fd5b505191905056fea2646970667358221220e04bdd073ad1aa256e3621499d2806a12346cb1e1cb612e3f9137b56251ff57564736f6c634300080a0033
1. airdropAmount

2. airdropAmounts

3. chunkSize

4. getRemainingCount

5. lastDistributedIndex

6. owner

7. recipients

8. USDT

1. addUser
2. distributeChunk
3. resetAirdrop
4. setChunkSize
5. transferOwnership
6. withdrawRemaining

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met.