# Smart Contract Schema

Understanding the contract schema is essential for developers working with the **TokenTable TVM**. This section provides an overview of the TLB (Type-Level Binary) schema, which defines the structure and relationships of the smart contract components for interaction within the TON blockchain.

### **TLB Structure**

The **TokenTable TVM** smart contract uses TLB to define the serialization format and logic for its data structures and functions. Below is the schema breakdown of the contract’s key components:

#### **Main Distributor Contract**

The **Main Distributor Contract** holds the merkle root for wallet verification and manages token distribution. Here’s the TLB schema for the contract:

```
main_distributor#_
    version:int             ;; Contract version
    admin_address:slice     ;; Admin address with management privileges
    root:int                ;; Merkle root for verifying claims
    deployer:slice          ;; Deployer address, initial contract creator
    token:slice             ;; Main Contract Jetton Wallet for distribution
    start_time:int          ;; Start time for token distribution
    end_time:int            ;; End time for token distribution
    leaf_code:cell          ;; Code for the leaf contracts
    claim_fee:int           ;; Fee required to submit a claim
    claim_fee_address:slice ;; Address to receive the claim fees
    paused:int              ;; Distribution paused status (1 = paused, 0 = active)
    feeless_threshold:int   ;; Claim threshold below which no fee is charged
    fee_accumulated:int     ;; Total fees accumulated from claims
    -> MainDistributor;
```

#### **Leaf Contract**

Each **Leaf Contract** verifies individual wallet claims by processing merkle proofs and triggering token transfers. Here’s the TLB schema for a leaf contract:

```
leaf_contract#_
    used:int               ;; Status indicating if the leaf has been used for a 
			   ;; claim (1 = used, 0 = unused)
    distributor:slice      ;; Address of the main distributor contract
    index:int              ;; Index of the leaf in the merkle tree
    -> LeafContract;
```

#### **Claim Transaction**

The claim transaction initiates the process of submitting a merkle proof and distributing tokens. Below is the TLB schema for submitting a claim:

```
claim_operation#_
    proof:cell          ;; Reference to the merkle proof (cell)
    index:uint64        ;; Index of the leaf in the merkle tree
    -> ClaimOperation;
```

#### **Token Transfer**

This defines the structure for token transfers triggered after successful claim verification:

```
token_transfer#_
    to_addr:bits256     ;; Recipient wallet address
    amount:uint64       ;; Amount of tokens to transfer
    -> TokenTransfer;
```

### **TLB Relationships**

To visualize the relationships between the TLB components, here's a conceptual breakdown:

* **Main Distributor Contract** holds the **merkle root** and manages the main jetton wallet.
* **Leaf Contracts** handle individual wallet verification using **merkle proofs** and communicate with the Main Distributor Contract for token transfers.
* **Claim Transactions** are submitted by users with **merkle proofs** and are processed by the Leaf Contracts.
* **Token Transfers** occur once the merkle proof is verified, resulting in the distribution of tokens to the user’s wallet.

***

In the following sections, we'll explore integration capabilities of the smart contract.
