# Signature Distributor

## Introduction

The EDDSA Distributor program provides signature-based token distribution using EDDSA signatures for claim verification. This approach offers an alternative to Merkle tree-based distributors, allowing for more flexible and dynamic claim authorizations.

## 🚀 Quick Start

### What is an EDDSA Distributor?

An EDDSA Distributor is a smart contract system that enables efficient token distribution using signature verification. Instead of storing a Merkle tree root, it uses cryptographic signatures from an authorized signer to validate claims, offering greater flexibility for dynamic distributions.

### Key Benefits

* ✅ **Dynamic Claims** - No need to generate Merkle trees in advance
* ✅ **Signature-Based** - Claims authorized via EDDSA signatures
* ✅ **Batch Processing** - Process multiple claims in one transaction

### Key Differences from Merkle Distributors

| Feature      | Merkle Distributor  | EDDSA Distributor |
| ------------ | ------------------- | ----------------- |
| Verification | Merkle proofs       | EDDSA signatures  |
| Data Storage | Merkle root         | Authorized signer |
| Claim Data   | Fixed at deployment | Dynamic per claim |
| Gas Cost     | Higher for setup    | Higher per claim  |
| Flexibility  | Limited             | High              |

## 📋 System Overview

### Account Structure

<figure><img src="/files/1yJMWKM0xlQgon2wuUX8" alt=""><figcaption></figcaption></figure>

### Storage Pattern

A contract has one config storage account, which stores the contract admin's account address and the default fee collector's deployment address. This account will also store a new admin's account address for secure two-step ownership transfers.

```rust
pub struct Config {
  pub admin: Pubkey,
  pub new_admin: Pubkey,
  pub default_fee_collector: Pubkey,
}
```

An EDDSA Distributor deployment can manage multiple airdrops. Airdrops use the following storage pattern:

```rust
pub struct Airdrop {
  pub owner: Pubkey,
  pub authorized_signer: Pubkey,
  pub token: Pubkey,
  pub start_time: u64,
  pub end_time: u64,
  pub fee_collector: Pubkey,
  pub fee_token: Pubkey,
  pub paused: bool,
}
```

### Claim Mechanism

Claim support with signature verification:

```rust
pub fn claim(
  ctx: Context<Claim>,
  project_id: String,
  recipient: Pubkey,
  user_claim_id: [u8; 32],
  group: [u8; 32],
  user_claim_data: EDDSADistributorData,
  signature: Vec<u8>
) -> Result<()>
```

**Security Features**

* ECDSA signature verification
* Pausable functionality
* Reentrancy protection
* Claim ID account initialization to prevent double claims

#### Key Functions

| Function          | Description                                     |
| ----------------- | ----------------------------------------------- |
| `initialize()`    | Initialize an airdrop, create required accounts |
| `setBaseParams()` | Sets token, time window, and authorized signer  |
| `claim()`         | Processes batch claims with signatures          |
| `togglePause()`   | Emergency pause functionality                   |
| `deposit()`       | Deposit tokens to be airdropped                 |

## 🔌 Distributor Variants

### EDDSADistributor

Standard implementation for token distribution.

**Data Structure:**

```rust
pub struct EDDSADistributorData {
  pub claimable_timestamp: u64,
  pub claimable_amount: u64,
}
```

**Key Features:**

* Supports both SPL and SPL2022 tokens
* Time-locked claims based on `claimable_timestamp`
* Standard withdrawal function for unclaimed tokens

### FungibleTokenWithFeesEDDSADistributor

Extension that includes fee data in the claim structure.

**Data Structure:**

```rust
pub struct EDDSADistributorData {
  pub claimable_timestamp: u64,
  pub claimable_amount: u64,
  pub fees: u64,
}
```

**Key Features:**

* Fees encoded in claim data
* Batch fee collection
* Mandatory fee collector configuration
* Custom fee amounts per claim

## 💰 Fee System

### Overview

The fee system provides flexible fee collection for claims.

### Components

1. **Fee Collector** - External `FeeCollector` program that calculates and manages vault accounts
2. **Fee Token** - Native or SPL token for fees
3. **Vault Accounts** - Program Derived Accounts (PDAs) for holding fee tokens

### Fee Implementations

1. **Fixed Fee** - Base implementation charges per claim or batch
2. **Custom Fee** - Extension allows per-claim fee amounts

## 🔒 Security

### Access Control

| Role              | Permissions                                    |
| ----------------- | ---------------------------------------------- |
| Program Admin     | Set fee collector, transfer program admin      |
| Airdrop Owner     | Set parameters, toggle pause, configure signer |
| Authorized Signer | Sign claim authorizations                      |
| Users             | Submit claims with valid signatures            |

### Security Features

* **Signature Verification** - ECDSA signature validation
* **Pausable** - Emergency stop functionality
* **Reentrancy Guards** - Protection against reentrancy attacks
* **Claim Tracking** - Prevents double claiming
* **Time Windows** - Enforced distribution periods

## 📡 Events & Errors

### Events

| Event              | Description                      |
| ------------------ | -------------------------------- |
| `Initialized`      | Successful aidrop initialization |
| `ClaimDelegateSet` | Successful claim delegate set    |
| `Claimed`          | Successful token claim           |

### Errors

| Error                       | Condition                                                                   |
| --------------------------- | --------------------------------------------------------------------------- |
| `UnsupportedOperation`      | Operation not allowed                                                       |
| `TimeInactive`              | Outside distribution window                                                 |
| `InvalidSignature`          | Signature verification failed                                               |
| `OutsideClaimableTimeRange` | Outside claim window                                                        |
| `NotOwner`                  | Unpermissioned account trying to call an owner-permissioned function        |
| `NotProgramAdmin`           | Unpermissioned account trying to call a program admin-permissioned function |
| `NotPermissioned`           | Unpermissioned account trying to receive program admin status               |
| `InvalidFeeCollector`       | Provided fee collector account is incorrect                                 |
| `Paused`                    | Airdrop has been paused                                                     |


---

# 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.tokentable.xyz/for-developers/airdrop/solana/signature-distributor.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.
