# Airdrop Contracts

### Key Features

* **ERC20 Token Distribution**: Supports airdropping any ERC20 token
* **Merkle Proof Verification**: Uses cryptographic proofs to verify claim eligibility
* **Gas Efficient**: Only stores one Merkle root instead of all user data
* **Claim Tracking**: Prevents double-claiming by maintaining a record of claimed addresses
* **Owner Controls**: Allows the owner to update the Merkle root and withdraw unclaimed tokens

{% embed url="<https://github.com/bio-xyz/airdrop-contracts>" %}

### MerkleAirdrop Contract

A contract that implements a Merkle tree–based airdrop for ERC20 tokens with controlled claim processing and robust admin management.

#### Features

* **Merkle Tree Eligibility:**
  * Utilizes a stored Merkle root to verify if an address is eligible for the airdrop.
  * The `inMerkle()` function checks a user's address and claim amount against the Merkle proof.
* **Claiming Process:**
  * Users can claim tokens via the `claim()` function if they are eligible.
  * Prevents double claims by tracking claims in a mapping.
  * Emits a `Claimed` event on successful claims.
* **Admin Controls:**
  * The owner can update the Merkle root using the `updateMerkleRoot()` function.
  * Allows the owner to withdraw tokens from the contract with the `withdraw()` function.

#### Inheritance

* **ReentrancyGuard:** Provides protection against reentrancy attacks on critical functions.
* **Ownable:** Restricts sensitive functions to the contract owner.

#### Key Functions

* **claim(uint256 amount, bytes32\[] calldata proof):** Allows eligible users to claim their tokens if their Merkle proof is valid.
* **inMerkle(address who, uint256 amount, bytes32\[] calldata proof):** Verifies that the address and claim amount are part of the Merkle tree.
* **hasClaimed(address who):** Checks whether an address has already claimed the airdrop.
* **updateMerkleRoot(bytes32 \_root):** Enables the owner to update the Merkle root to adjust eligibility.
* **withdraw(address recipient, uint256 amount):** Allows the owner to withdraw tokens from the contract if needed.

#### Security Features

* **Reentrancy Protection:** Critical functions (like `claim()`) are secured against reentrant calls.
* **Safe Transfers:** Utilizes the SafeERC20 library to ensure secure token transfers.
* **Access Control:** Owner-only functions safeguard administrative tasks such as updating the Merkle root and withdrawing tokens.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bio.xyz/bio/developers/dao-setup/evm-contracts/airdrop-contracts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
