Address Contract Verified
Address
0xdf9aCedDd8a8C130DFe3015C0b1B507cf6571fc9
Balance
0 ETH
Nonce
1
Code Size
5487 bytes
Creator
0xE4476803...42d9 at tx 0xbaf4a7cc...bb22e7
Indexed Transactions
0
Contract Bytecode
5487 bytes
0x60806040526004361015610011575f80fd5b5f3560e01c80630bcae1ac14610ce257806325aa22d814610c715780632eb4a7ab14610c54578063315a095d14610a4b5780633ba86c4414610a2e5780633f4ba83a146109915780635312ea8e146107345780635c975abb146107125780635d34f4a6146106c0578063715018a6146106445780637c382d0b1461053b5780638456cb59146104c45780638da5cb5b146104925780639845171814610466578063bc5bf5ca14610334578063c59d48471461022e578063dac6270d1461020c578063f2fde38b1461013e5763fc0c546a146100ea575f80fd5b3461013a575f60031936011261013a57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000904567252d8f48555b7447c67dca23f0372e16be168152f35b5f80fd5b3461013a57602060031936011261013a5773ffffffffffffffffffffffffffffffffffffffff61016c61111a565b6101746114ed565b1680156101e05773ffffffffffffffffffffffffffffffffffffffff5f54827fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f55167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b3461013a575f60031936011261013a576020610226611412565b604051908152f35b3461013a575f60031936011261013a576102466114ed565b60065460075490604051917f70a0823100000000000000000000000000000000000000000000000000000000835230600484015260208360248173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000904567252d8f48555b7447c67dca23f0372e16be165afa8015610329575f906102f6575b60c093506003549060045492604051948552602085015260408401526060830152806080830152421060a0820152f35b506020833d602011610321575b81610310602093836111a2565b8101031261013a5760c092516102c6565b3d9150610303565b6040513d5f823e3d90fd5b3461013a57606060031936011261013a5761034d61111a565b6024356044359167ffffffffffffffff831161013a576103fa61037660409436906004016110e9565b8551606085901b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660208201908152603482018790526103f5916103e681605481015b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018352826111a2565b51902092600354923691611275565b61149c565b91829182610437575b508161042b575b81610421575b508251911515825215156020820152f35b9050151583610410565b6004544210915061040a565b73ffffffffffffffffffffffffffffffffffffffff919250165f52600560205260ff835f205416159084610403565b3461013a575f60031936011261013a57335f526005602052602060ff60405f2054166040519015158152f35b3461013a575f60031936011261013a57602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b3461013a575f60031936011261013a576104dc6114ed565b6104e461142f565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0060025416176002557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b3461013a57604060031936011261013a5760043560243561055a6114ed565b81156105e6576301e1338042018042116105b9578161059d6020927fecb6e184c8c1ff50ab199b30650a76b7eb56fe2f261becc6284e0a3a1707be489410611348565b6105a84282116113ad565b8360035580600455604051908152a2005b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964204d65726b6c6520726f6f74000000000000000000000000006044820152fd5b3461013a575f60031936011261013a5761065c6114ed565b5f73ffffffffffffffffffffffffffffffffffffffff81547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461013a57602060031936011261013a5773ffffffffffffffffffffffffffffffffffffffff6106ee61111a565b6106f66114ed565b165f526005602052602060ff60405f2054166040519015158152f35b3461013a575f60031936011261013a57602060ff600254166040519015158152f35b3461013a57602060031936011261013a576004356107506114ed565b610758611463565b61076381151561113d565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000904567252d8f48555b7447c67dca23f0372e16be166040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481855afa8015610329575f9061095d575b6107e99150831115611210565b6003546108d9575f80546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201526024810184905291602091839160449183915af1801561032957610861915f916108aa575b506112e3565b7f2e39961a70a10f4d46383948095ac2752b3ee642a7c76aa827410aaff08c2e51602073ffffffffffffffffffffffffffffffffffffffff5f541692604051908152a260018055005b6108cc915060203d6020116108d2575b6108c481836111a2565b8101906112cb565b8361085b565b503d6108ba565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f43616e206f6e6c7920656d657267656e6379207769746864726177206265666f60448201527f7265206d65726b6c6520726f6f742069732073657400000000000000000000006064820152fd5b506020813d602011610989575b81610977602093836111a2565b8101031261013a576107e990516107dc565b3d915061096a565b3461013a575f60031936011261013a576109a96114ed565b60025460ff811615610a06577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166002557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b000000000000000000000000000000000000000000000000000000005f5260045ffd5b3461013a575f60031936011261013a576020600454604051908152f35b3461013a57602060031936011261013a57600435610a676114ed565b610a6f611463565b610a7a81151561113d565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000904567252d8f48555b7447c67dca23f0372e16be166040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481855afa8015610329575f90610c20575b610b009150831115611210565b6004544210610bc2575f80546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201526024810184905291602091839160449183915af1801561032957610b79915f916108aa57506112e3565b7f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b602073ffffffffffffffffffffffffffffffffffffffff5f541692604051908152a260018055005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f43616e206f6e6c7920776974686472617720616674657220646561646c696e656044820152fd5b506020813d602011610c4c575b81610c3a602093836111a2565b8101031261013a57610b009051610af3565b3d9150610c2d565b3461013a575f60031936011261013a576020600354604051908152f35b3461013a57602060031936011261013a57600435610c8d6114ed565b6301e1338042018042116105b95781610cca6020927ffaa5516963624f4790f0dd54d004b8433097b12b3b13a5e6d7e36ed88c83e8209410611348565b610cd54282116113ad565b80600455604051908152a1005b3461013a57604060031936011261013a5760043560243567ffffffffffffffff811161013a57610d169036906004016110e9565b90610d1f61142f565b610d27611463565b60035491821561108b5760045442101561102d57335f52600560205260ff60405f205416610fcf57610d5a84151561113d565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000904567252d8f48555b7447c67dca23f0372e16be16926040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481885afa908115610329575f91610f9b575b50610e3993610de96103f592881115611210565b6040513360601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602082019081526034820189905290610e2e81605481016103ba565b519020933691611275565b15610f3d57335f52600560205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790556006547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146105b9576001016006556007548281018091116105b9576007556040517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201526024810183905290602090829060449082905f905af1801561032957610f0b915f916108aa57506112e3565b6040519081527f650e45f04ef8a0c267b2f78d983913f69ae3a353b2b32de5429307522be0ab5560203392a260018055005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c6964204d65726b6c652070726f6f660000000000000000000000006044820152fd5b90506020813d602011610fc7575b81610fb6602093836111a2565b8101031261013a5751610e39610dd5565b3d9150610fa9565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f416c726561647920636c61696d656400000000000000000000000000000000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f436c61696d20646561646c696e652068617320706173736564000000000000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d65726b6c6520726f6f74206e6f7420736574000000000000000000000000006044820152fd5b9181601f8401121561013a5782359167ffffffffffffffff831161013a576020808501948460051b01011161013a57565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361013a57565b1561114457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152fd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176111e357604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b1561121757565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f496e73756666696369656e7420636f6e74726163742062616c616e63650000006044820152fd5b9291909267ffffffffffffffff84116111e3578360051b90602060405161129e828501826111a2565b809681520191810192831161013a57905b8282106112bb57505050565b81358152602091820191016112af565b9081602091031261013a5751801515810361013a5790565b156112ea57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152fd5b1561134f57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f446561646c696e65206d7573742062652077697468696e2031207965617200006044820152fd5b156113b457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f446561646c696e65206d75737420626520696e207468652066757475726500006044820152fd5b6004548042101561142a574281039081116105b95790565b505f90565b60ff6002541661143b57565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b600260015414611474576002600155565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b929091905f915b84518310156114e55760208360051b86010151908181105f146114d4575f52602052600160405f205b9201916114a3565b905f52602052600160405f206114cc565b915092501490565b73ffffffffffffffffffffffffffffffffffffffff5f5416330361150d57565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffdfea2646970667358221220491b498ffcd1fa75ac95dd7da42e0df4263458f1ca5434cdf4855b931be9f36a64736f6c634300081c0033
Verified Source Code Full Match
Compiler: v0.8.28+commit.7893614a
EVM: cancun
Optimization: Yes (20000 runs)
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);
}
}
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;
}
}
Hashes.sol 31 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/Hashes.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of standard hash functions.
*
* _Available since v5.1._
*/
library Hashes {
/**
* @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
*
* NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
*/
function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {
assembly ("memory-safe") {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
MerkleProof.sol 514 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MerkleProof.sol)
// This file was procedurally generated from scripts/generate/templates/MerkleProof.js.
pragma solidity ^0.8.20;
import {Hashes} from "./Hashes.sol";
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*
* IMPORTANT: Consider memory side-effects when using custom hashing functions
* that access memory in an unsafe way.
*
* NOTE: This library supports proof verification for merkle trees built using
* custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
* leaf inclusion in trees built using non-commutative hashing functions requires
* additional logic that is not supported by this library.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProof(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function processProof(
bytes32[] memory proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProofCalldata(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function processProofCalldata(
bytes32[] calldata proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProof(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
}
Pausable.sol 112 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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 {
bool private _paused;
/**
* @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);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @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 {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @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());
}
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* 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;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
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
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// 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;
}
}
KiteAirdrop.sol 203 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
/**
* @title KiteAirdrop
* @dev Merkle tree-based airdrop contract for distributing tokens to eligible wallets
*/
contract KiteAirdrop is Ownable, ReentrancyGuard, Pausable {
IERC20 public immutable token;
bytes32 public merkleRoot;
uint256 public claimDeadline;
mapping(address => bool) internal hasClaimed;
uint256 private _totalClaimed;
uint256 private _totalTokensClaimed;
event MerkleRootUpdated(bytes32 indexed newRoot, uint256 deadline);
event AirdropClaimed(address indexed wallet, uint256 amount);
event ClaimDeadlineUpdated(uint256 newDeadline);
event TokensWithdrawn(address indexed owner, uint256 amount);
event EmergencyWithdrawn(address indexed owner, uint256 amount);
event AirdropPaused();
event AirdropUnpaused();
/**
* @dev Constructor sets the token address
* @param tokenAddress The address of the ERC20 token to distribute
*/
constructor(address tokenAddress) Ownable(msg.sender) {
require(tokenAddress != address(0), "Invalid token address");
token = IERC20(tokenAddress);
}
/**
* @dev Set the Merkle root and claim deadline
* @param _merkleRoot The Merkle root of eligible wallets and amounts
* @param _claimDeadline The timestamp when claiming ends
*/
function setMerkleRoot(bytes32 _merkleRoot, uint256 _claimDeadline) external onlyOwner {
require(_merkleRoot != bytes32(0), "Invalid Merkle root");
require(_claimDeadline < block.timestamp + 365 days, "Deadline must be within 1 year");
require(_claimDeadline > block.timestamp, "Deadline must be in the future");
merkleRoot = _merkleRoot;
claimDeadline = _claimDeadline;
emit MerkleRootUpdated(_merkleRoot, _claimDeadline);
}
/**
* @dev Update the claim deadline
* @param _claimDeadline The new timestamp when claiming ends
*/
function setClaimDeadline(uint256 _claimDeadline) external onlyOwner {
require(_claimDeadline < block.timestamp + 365 days, "Deadline must be within 1 year");
require(_claimDeadline > block.timestamp, "Deadline must be in the future");
claimDeadline = _claimDeadline;
emit ClaimDeadlineUpdated(_claimDeadline);
}
/**
* @dev Claim tokens using Merkle proof
* @param amount The amount of tokens to claim
* @param proof The Merkle proof proving eligibility
*/
function claimAirdrop(uint256 amount, bytes32[] calldata proof) external whenNotPaused nonReentrant {
require(merkleRoot != bytes32(0), "Merkle root not set");
require(block.timestamp < claimDeadline, "Claim deadline has passed");
require(!hasClaimed[msg.sender], "Already claimed");
require(amount > 0, "Amount must be greater than 0");
require(amount <= token.balanceOf(address(this)), "Insufficient contract balance");
// Verify the Merkle proof
bytes32 leaf = keccak256(abi.encodePacked(msg.sender, amount));
bool isValidProof = MerkleProof.verify(proof, merkleRoot, leaf);
require(isValidProof, "Invalid Merkle proof");
// Mark as claimed and transfer tokens
hasClaimed[msg.sender] = true;
_totalClaimed++;
_totalTokensClaimed += amount;
require(token.transfer(msg.sender, amount), "Transfer failed");
emit AirdropClaimed(msg.sender, amount);
}
/**
* @dev Check if a wallet is eligible to claim
* @param wallet The wallet address to check
* @param amount The amount to check eligibility for
* @param proof The Merkle proof to verify
* @return isEligible Whether the wallet is eligible
* @return canClaim Whether the wallet can claim (not already claimed and within deadline)
*/
function checkEligibility(address wallet, uint256 amount, bytes32[] calldata proof) external view returns (bool isEligible, bool canClaim) {
bytes32 leaf = keccak256(abi.encodePacked(wallet, amount));
isEligible = MerkleProof.verify(proof, merkleRoot, leaf);
canClaim = isEligible && !hasClaimed[wallet] && block.timestamp < claimDeadline && amount > 0;
}
/**
* @dev Check if the caller has already claimed
* @return claimed Whether the caller has claimed
*/
function checkMyClaimStatus() external view returns (bool claimed) {
return hasClaimed[msg.sender];
}
/**
* @dev Check if a wallet has already claimed (owner only for admin purposes)
* @param wallet The wallet address to check
* @return claimed Whether the wallet has claimed
*/
function hasWalletClaimed(address wallet) external view onlyOwner returns (bool claimed) {
return hasClaimed[wallet];
}
/**
* @dev Get the time remaining for claims
* @return timeRemaining The time remaining in seconds, 0 if deadline has passed
*/
function getTimeRemaining() external view returns (uint256 timeRemaining) {
if (block.timestamp >= claimDeadline) {
return 0;
}
return claimDeadline - block.timestamp;
}
/**
* @dev Get contract stats (owner only)
* @return totalClaimedCount Total number of wallets that have claimed
* @return totalTokensClaimedCount Total tokens claimed
* @return contractTokenBalance Token balance of the contract
* @return currentMerkleRoot Current Merkle root
* @return deadlineTimestamp Claim deadline timestamp
* @return isClaimingActive Whether claiming is still active
*/
function getStats() external view onlyOwner returns (
uint256 totalClaimedCount,
uint256 totalTokensClaimedCount,
uint256 contractTokenBalance,
bytes32 currentMerkleRoot,
uint256 deadlineTimestamp,
bool isClaimingActive
) {
return (
_totalClaimed,
_totalTokensClaimed,
token.balanceOf(address(this)),
merkleRoot,
claimDeadline,
block.timestamp < claimDeadline
);
}
/**
* @dev Withdraw remaining tokens from the contract after deadline
* @param amount The amount to withdraw
*/
function withdrawTokens(uint256 amount) external onlyOwner nonReentrant {
require(amount > 0, "Amount must be greater than 0");
require(amount <= token.balanceOf(address(this)), "Insufficient contract balance");
require(block.timestamp >= claimDeadline, "Can only withdraw after deadline");
require(token.transfer(owner(), amount), "Transfer failed");
emit TokensWithdrawn(owner(), amount);
}
/**
* @dev Emergency function to withdraw tokens before deadline (in case of issues)
* @param amount The amount to withdraw
*/
function emergencyWithdraw(uint256 amount) external onlyOwner nonReentrant {
require(amount > 0, "Amount must be greater than 0");
require(amount <= token.balanceOf(address(this)), "Insufficient contract balance");
require(merkleRoot == bytes32(0), "Can only emergency withdraw before merkle root is set");
require(token.transfer(owner(), amount), "Transfer failed");
emit EmergencyWithdrawn(owner(), amount);
}
/**
* @dev Pause the airdrop (emergency only)
*/
function pause() external onlyOwner {
_pause();
}
/**
* @dev Unpause the airdrop
*/
function unpause() external onlyOwner {
_unpause();
}
}
Read Contract
checkEligibility 0xbc5bf5ca → bool, bool
checkMyClaimStatus 0x98451718 → bool
claimDeadline 0x3ba86c44 → uint256
getStats 0xc59d4847 → uint256, uint256, uint256, bytes32, uint256, bool
getTimeRemaining 0xdac6270d → uint256
hasWalletClaimed 0x5d34f4a6 → bool
merkleRoot 0x2eb4a7ab → bytes32
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
token 0xfc0c546a → address
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
claimAirdrop 0x0bcae1ac
uint256 amount
bytes32[] proof
emergencyWithdraw 0x5312ea8e
uint256 amount
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
setClaimDeadline 0x25aa22d8
uint256 _claimDeadline
setMerkleRoot 0x7c382d0b
bytes32 _merkleRoot
uint256 _claimDeadline
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
withdrawTokens 0x315a095d
uint256 amount
Recent Transactions
No transactions found for this address