> ## Documentation Index
> Fetch the complete documentation index at: https://www.zkcompression.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Interface PDAs for Compression to Existing Mints

> Create an interface PDA for an existing SPL mint. Requires only fee_payer with no mint authority constraint.

Create an interface PDA for compression for an existing SPL mint. `createTokenPool()` requires only `fee_payer` and has no mint authority constraint.

> [!NOTE]
>
> The interface PDA itself requires rent, but individual compressed token accounts are rent-free.

```typescript function-create-token-pool.ts theme={null}
// Creates interface PDA for existing SPL mint
const transactionSignature = await createTokenPool(
    rpc,
    payer,
    mint,
);
```

> [!TIP]
>
> **Best Practice:** Each mint supports a maximum of 4 interface PDAs total. During compression/decompression operations, interface PDAs get write-locked. Use `addTokenPools()` to create additional PDAs that increase per-block write-lock capacity.

## Get Started

**Step 1**

### Create Interface PDA

> [accordion] Installation
>
> > [tab] npm
> >
> > Install packages in your working directory:
> >
> > ```bash theme={null}
> > npm install @lightprotocol/stateless.js@^0.23.0 \
> >             @lightprotocol/compressed-token@^0.23.0
> > ```
> >
> > Install the CLI globally:
> >
> > ```bash theme={null}
> > npm install -g @lightprotocol/zk-compression-cli
> > ```
>
> > [tab] yarn
> >
> > Install packages in your working directory:
> >
> > ```bash theme={null}
> > yarn add @lightprotocol/stateless.js@^0.23.0 \
> >          @lightprotocol/compressed-token@^0.23.0
> > ```
> >
> > Install the CLI globally:
> >
> > ```bash theme={null}
> > yarn global add @lightprotocol/zk-compression-cli
> > ```
>
> > [tab] pnpm
> >
> > Install packages in your working directory:
> >
> > ```bash theme={null}
> > pnpm add @lightprotocol/stateless.js@^0.23.0 \
> >          @lightprotocol/compressed-token@^0.23.0
> > ```
> >
> > Install the CLI globally:
> >
> > ```bash theme={null}
> > pnpm add -g @lightprotocol/zk-compression-cli
> > ```
>
> > [tab] SDK 2.0 (token-interface)
> >
> > Install packages in your working directory:
> >
> > ```bash theme={null}
> > # npm
> > npm install @lightprotocol/stateless.js@^0.23.0 \
> >             @lightprotocol/token-interface@^0.1.2
> >
> > # yarn
> > yarn add @lightprotocol/stateless.js@^0.23.0 \
> >          @lightprotocol/token-interface@^0.1.2
> >
> > # pnpm
> > pnpm add @lightprotocol/stateless.js@^0.23.0 \
> >          @lightprotocol/token-interface@^0.1.2
> > ```
> >
> > Install the CLI globally:
> >
> > ```bash theme={null}
> > npm install -g @lightprotocol/zk-compression-cli
> > ```

> [tab] Localnet
>
> ```bash theme={null}
> # start local test-validator in a separate terminal
> light test-validator
> ```
>
> > [!NOTE]
> >
> > In the code examples, use `createRpc()` without arguments for localnet.

> [tab] Devnet
>
> Get an API key from [Helius](https://helius.dev) and add to `.env`:
>
> ```bash title=".env" theme={null}
> API_KEY=<your-helius-api-key>
> ```
>
> > [!NOTE]
> >
> > In the code examples, use `createRpc(RPC_URL)` with the devnet URL.

```typescript theme={null}
import "dotenv/config";
import { Keypair, PublicKey } from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { createTokenPool } from "@lightprotocol/compressed-token";
import { createMint as createSplMint, TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { homedir } from "os";
import { readFileSync } from "fs";

// devnet:
const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
// localnet:
// const RPC_URL = undefined;
const payer = Keypair.fromSecretKey(
    new Uint8Array(
        JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))
    )
);

(async function () {
    // devnet:
    const rpc = createRpc(RPC_URL);
    // localnet:
    // const rpc = createRpc();

    // Setup: Create existing SPL mint
    const mintKeypair = Keypair.generate();
    await createSplMint(rpc, payer, payer.publicKey, null, 9, mintKeypair, undefined, TOKEN_PROGRAM_ID);

    // Create interface PDA for existing mint
    const tx = await createTokenPool(rpc, payer, mintKeypair.publicKey);

    console.log("Mint:", mintKeypair.publicKey.toBase58());
    console.log("Tx:", tx);
})();
```

# Troubleshooting

> [accordion] TokenPool not found
>
> You're trying to access an interface PDA that doesn't exist.
>
> ```typescript theme={null}
> // Create the missing interface PDA
> const poolTx = await createTokenPool(rpc, payer, mint);
> console.log("Interface PDA created:", poolTx);
> ```

# Advanced Configuration

> [accordion] Batch Pool Creation
>
> Create pools for multiple mints:
>
> ```typescript theme={null}
> const mints = [
>     new PublicKey("MINT_1_ADDRESS"),
>     new PublicKey("MINT_2_ADDRESS"),
>     new PublicKey("MINT_3_ADDRESS"),
> ];
>
> for (const mint of mints) {
>     try {
>         const poolTx = await createTokenPool(rpc, payer, mint);
>         console.log(`Pool created for ${mint.toBase58()}:`, poolTx);
>     } catch (error) {
>         console.log(`Failed for ${mint.toBase58()}:`, error.message);
>     }
> }
> ```

> [accordion] Create Pool with Token-2022
>
> Create interface PDAs for Token-2022 mints:
>
> ```typescript theme={null}
> import { TOKEN_2022_PROGRAM_ID } from '@solana/spl-token';
>
> const poolTx = await createTokenPool(
>     rpc,
>     payer,
>     mint, // Token-2022 mint
>     undefined,
>     TOKEN_2022_PROGRAM_ID,
> );
> ```

# Next Steps

> [card] [How to Merge Compressed Token Accounts](https://www.zkcompression.com/compressed-tokens/guides/merge-compressed-token-accounts.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.