creation_sourcecode: // SPDX-License-Identifier: MIT
  
  pragma solidity ^0.8.19;
  
  abstract contract Context {
      function _msgSender() internal view virtual returns (address) {
          return msg.sender;
      }
  
      function _msgData() internal view virtual returns (bytes memory) {
          this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
          return msg.data;
      }
  }
  
  abstract contract Ownable is Context {
      address private _owner;
  
      event OwnershipTransferred(
          address indexed previousOwner,
          address indexed newOwner
      );
  
      /**
       * @dev Initializes the contract setting the deployer as the initial owner.
       */
      constructor() {
          address msgSender = _msgSender();
          _owner = msgSender;
          emit OwnershipTransferred(address(0), msgSender);
      }
  
      /**
       * @dev Returns the address of the current owner.
       */
      function owner() public view returns (address) {
          return _owner;
      }
  
      /**
       * @dev Throws if called by any account other than the owner.
       */
      modifier onlyOwner() {
          require(_owner == _msgSender(), "Ownable: caller is not the owner");
          _;
      }
  
      /**
       * @dev Leaves the contract without owner. It will not be possible to call
       * `onlyOwner` functions anymore. Can only be called by the current owner.
       *
       * NOTE: Renouncing ownership will leave the contract without an owner,
       * thereby removing any functionality that is only available to the owner.
       */
      function renounceOwnership() public virtual onlyOwner {
          emit OwnershipTransferred(_owner, address(0));
          _owner = 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 {
          require(
              newOwner != address(0),
              "Ownable: new owner is the zero address"
          );
          emit OwnershipTransferred(_owner, newOwner);
          _owner = newOwner;
      }
  }
  
  library SafeMath {
      /**
       * @dev Returns the addition of two unsigned integers, reverting on
       * overflow.
       *
       * Counterpart to Solidity's `+` operator.
       *
       * Requirements:
       *
       * - Addition cannot overflow.
       */
      function add(uint256 a, uint256 b) internal pure returns (uint256) {
          uint256 c = a + b;
          require(c >= a, "SafeMath: addition overflow");
  
          return c;
      }
  
      /**
       * @dev Returns the subtraction of two unsigned integers, reverting on
       * overflow (when the result is negative).
       *
       * Counterpart to Solidity's `-` operator.
       *
       * Requirements:
       *
       * - Subtraction cannot overflow.
       */
      function sub(uint256 a, uint256 b) internal pure returns (uint256) {
          return sub(a, b, "SafeMath: subtraction overflow");
      }
  
      /**
       * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
       * overflow (when the result is negative).
       *
       * Counterpart to Solidity's `-` operator.
       *
       * Requirements:
       *
       * - Subtraction cannot overflow.
       */
      function sub(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b <= a, errorMessage);
          uint256 c = a - b;
  
          return c;
      }
  
      /**
       * @dev Returns the multiplication of two unsigned integers, reverting on
       * overflow.
       *
       * Counterpart to Solidity's `*` operator.
       *
       * Requirements:
       *
       * - Multiplication cannot overflow.
       */
      function mul(uint256 a, uint256 b) internal pure returns (uint256) {
          // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
          // benefit is lost if 'b' is also tested.
          // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
          if (a == 0) {
              return 0;
          }
  
          uint256 c = a * b;
          require(c / a == b, "SafeMath: multiplication overflow");
  
          return c;
      }
  
      /**
       * @dev Returns the integer division of two unsigned integers. Reverts on
       * division by zero. The result is rounded towards zero.
       *
       * Counterpart to Solidity's `/` operator. Note: this function uses a
       * `revert` opcode (which leaves remaining gas untouched) while Solidity
       * uses an invalid opcode to revert (consuming all remaining gas).
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function div(uint256 a, uint256 b) internal pure returns (uint256) {
          return div(a, b, "SafeMath: division by zero.");
      }
  
      /**
       * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
       * division by zero. The result is rounded towards zero.
       *
       * Counterpart to Solidity's `/` operator. Note: this function uses a
       * `revert` opcode (which leaves remaining gas untouched) while Solidity
       * uses an invalid opcode to revert (consuming all remaining gas).
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function div(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b > 0, errorMessage);
          uint256 c = a / b;
          // assert(a == b * c + a % b); // There is no case in which this doesn't hold
  
          return c;
      }
  
      /**
       * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
       * Reverts when dividing by zero.
       *
       * Counterpart to Solidity's `%` operator. This function uses a `revert`
       * opcode (which leaves remaining gas untouched) while Solidity uses an
       * invalid opcode to revert (consuming all remaining gas).
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function mod(uint256 a, uint256 b) internal pure returns (uint256) {
          return mod(a, b, "SafeMath: modulo by zero");
      }
  
      /**
       * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
       * Reverts with custom message when dividing by zero.
       *
       * Counterpart to Solidity's `%` operator. This function uses a `revert`
       * opcode (which leaves remaining gas untouched) while Solidity uses an
       * invalid opcode to revert (consuming all remaining gas).
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function mod(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b != 0, errorMessage);
          return a % b;
      }
  }
  
  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 make it call a
       * `private` function that does the actual work.
       */
      modifier nonReentrant() {
          // On the first call to nonReentrant, _notEntered will be true
          require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
  
          // Any calls to nonReentrant after this point will fail
          _status = _ENTERED;
  
          _;
  
          // By storing the original value once again, a refund is triggered (see
          // https://eips.ethereum.org/EIPS/eip-2200)
          _status = _NOT_ENTERED;
      }
  }
  
  library TransferHelper {
      function safeApprove(address token, address to, uint value) internal {
          (bool success, bytes memory data) = token.call(
              abi.encodeWithSelector(0x095ea7b3, to, value)
          );
          require(
              success && (data.length == 0 || abi.decode(data, (bool))),
              "TransferHelper: APPROVE_FAILED"
          );
      }
  
      function safeTransfer(address token, address to, uint value) internal {
          (bool success, bytes memory data) = token.call(
              abi.encodeWithSelector(0xa9059cbb, to, value)
          );
          require(
              success && (data.length == 0 || abi.decode(data, (bool))),
              "TransferHelper: TRANSFER_FAILED"
          );
      }
  
      function safeTransferFrom(
          address token,
          address from,
          address to,
          uint value
      ) internal {
          (bool success, bytes memory data) = token.call(
              abi.encodeWithSelector(0x23b872dd, from, to, value)
          );
          require(
              success && (data.length == 0 || abi.decode(data, (bool))),
              "TransferHelper: TRANSFER_FROM_FAILED"
          );
      }
  
      // sends ETH or an erc20 token
      function safeTransferBaseToken(
          address token,
          address payable to,
          uint value,
          bool isERC20
      ) internal {
          if (!isERC20) {
              to.transfer(value);
          } else {
              (bool success, bytes memory data) = token.call(
                  abi.encodeWithSelector(0xa9059cbb, to, value)
              );
              require(
                  success && (data.length == 0 || abi.decode(data, (bool))),
                  "TransferHelper: TRANSFER_FAILED"
              );
          }
      }
  }
  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.
       */
      function verify(
          bytes32[] memory proof,
          bytes32 root,
          bytes32 leaf
      ) internal pure returns (bool) {
          return processProof(proof, leaf) == root;
      }
  
      /**
       * @dev Calldata version of {verify}
       */
      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 leafs & pre-images are assumed to be sorted.
       */
      function processProof(
          bytes32[] memory proof,
          bytes32 leaf
      ) internal pure returns (bytes32) {
          bytes32 computedHash = leaf;
          for (uint256 i = 0; i < proof.length; i++) {
              computedHash = _hashPair(computedHash, proof[i]);
          }
          return computedHash;
      }
  
      /**
       * @dev Calldata version of {processProof}
       */
      function processProofCalldata(
          bytes32[] calldata proof,
          bytes32 leaf
      ) internal pure returns (bytes32) {
          bytes32 computedHash = leaf;
          for (uint256 i = 0; i < proof.length; i++) {
              computedHash = _hashPair(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}.
       *
       * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
       */
      function multiProofVerify(
          bytes32[] memory proof,
          bool[] memory proofFlags,
          bytes32 root,
          bytes32[] memory leaves
      ) internal pure returns (bool) {
          return processMultiProof(proof, proofFlags, leaves) == root;
      }
  
      /**
       * @dev Calldata version of {multiProofVerify}
       *
       * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
       */
      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.
       *
       * 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).
       */
      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 proofLen = proof.length;
          uint256 totalHashes = proofFlags.length;
  
          // Check proof validity.
          if (leavesLen + proofLen != totalHashes + 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[](totalHashes);
          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 < totalHashes; i++) {
              bytes32 a = leafPos < leavesLen
                  ? leaves[leafPos++]
                  : hashes[hashPos++];
              bytes32 b = proofFlags[i]
                  ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                  : proof[proofPos++];
              hashes[i] = _hashPair(a, b);
          }
  
          if (totalHashes > 0) {
              if (proofPos != proofLen) {
                  revert MerkleProofInvalidMultiproof();
              }
              unchecked {
                  return hashes[totalHashes - 1];
              }
          } else if (leavesLen > 0) {
              return leaves[0];
          } else {
              return proof[0];
          }
      }
  
      /**
       * @dev Calldata version of {processMultiProof}.
       *
       * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
       */
      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 proofLen = proof.length;
          uint256 totalHashes = proofFlags.length;
  
          // Check proof validity.
          if (leavesLen + proofLen != totalHashes + 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[](totalHashes);
          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 < totalHashes; i++) {
              bytes32 a = leafPos < leavesLen
                  ? leaves[leafPos++]
                  : hashes[hashPos++];
              bytes32 b = proofFlags[i]
                  ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                  : proof[proofPos++];
              hashes[i] = _hashPair(a, b);
          }
  
          if (totalHashes > 0) {
              if (proofPos != proofLen) {
                  revert MerkleProofInvalidMultiproof();
              }
              unchecked {
                  return hashes[totalHashes - 1];
              }
          } else if (leavesLen > 0) {
              return leaves[0];
          } else {
              return proof[0];
          }
      }
  
      /**
       * @dev Sorts the pair (a, b) and hashes the result.
       */
      function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
          return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
      }
  
      /**
       * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
       */
      function _efficientHash(
          bytes32 a,
          bytes32 b
      ) private pure returns (bytes32 value) {
          /// @solidity memory-safe-assembly
          assembly {
              mstore(0x00, a)
              mstore(0x20, b)
              value := keccak256(0x00, 0x40)
          }
      }
  }
  
  contract AirdropContract is ReentrancyGuard {
      using SafeMath for uint256;
  
      address owner;
      bytes32 public merkleRoot =
          0xf56723172e22637f60eb3072383e712d8cd615011ffa6b8c7ed96eaaa1b4a254;
      modifier onlyOwner() {
          require(owner == msg.sender, "Not contract owner.");
          _;
      }
  
      constructor() {
          owner = msg.sender;
      }
      receive() external payable {}
      struct Proof {
          uint256 _ethAmount;
          address _address;
          bytes32[] _merkleProof;
      }
  
      function airdrop(Proof[] calldata proofs) public nonReentrant {
          for (uint i = 0; i < proofs.length; i++) {
              require(verifyAddress(proofs[i]), "Must be member in whiteList");
              payable(proofs[i]._address).transfer(proofs[i]._ethAmount);
          }
      }
  
      function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
          merkleRoot = _merkleRoot;
      }
  
      function verifyAddress(Proof calldata _proof) private view returns (bool) {
          bytes32 leaf = keccak256(abi.encodePacked(_proof._address));
          return MerkleProof.verify(_proof._merkleProof, merkleRoot, leaf);
      }
  
      function withdraw(uint256 _amount) public onlyOwner {
          require(address(this).balance >= _amount, "Not enough balance");
          payable(msg.sender).transfer(_amount);
      }
  }