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

# Presale Vault TS SDK Getting Started

> Learn how to install @meteora-ag/presale, create a client, derive Presale Vault PDAs, and build your first transactions.

This guide shows how to install and initialize the official Presale Vault TypeScript SDK, `@meteora-ag/presale-sdk`.

Before you begin, here are the main resources:

<CardGroup cols={2}>
  <Card title="TypeScript SDK" icon="node-js" iconType="solid" href="https://github.com/MeteoraAg/presale-sdk">
    Presale Vault TypeScript SDK Repository
  </Card>

  <Card title="Presale Vault NPM Package" icon="npm" iconType="solid" href="https://www.npmjs.com/package/@meteora-ag/presale">
    Published package for transaction builders, PDAs, wrappers, and helpers.
  </Card>
</CardGroup>

## Install

To use the SDK in your project, install it using your preferred package manager:

<Tabs>
  <Tab title="npm">
    ```bash theme={"system"}
    npm install @meteora-ag/presale @solana/web3.js
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={"system"}
    pnpm install @meteora-ag/presale @solana/web3.js
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={"system"}
    yarn add @meteora-ag/presale @solana/web3.js
    ```
  </Tab>
</Tabs>

## Dependencies

| Package             | Version   |
| ------------------- | --------- |
| `@coral-xyz/anchor` | `^0.31.1` |
| `@solana/web3.js`   | `^1.98.2` |
| `@solana/spl-token` | `^0.4.13` |
| `bn.js`             | `^5.2.2`  |
| `decimal.js`        | `^10.6.0` |

## Create A Client

Create a client from an existing presale address:

```typescript theme={"system"}
import { Connection, PublicKey } from "@solana/web3.js";
import Presale, { PRESALE_PROGRAM_ID, derivePresale } from "@meteora-ag/presale";

const connection = new Connection(process.env.RPC_URL!, "confirmed");

const baseMint = new PublicKey("BASE_MINT_ADDRESS");
const quoteMint = new PublicKey("QUOTE_MINT_ADDRESS");
const base = new PublicKey("BASE_KEY_ADDRESS");

const presaleAddress = derivePresale(
  baseMint,
  quoteMint,
  base,
  PRESALE_PROGRAM_ID
);

const presale = await Presale.create(
  connection,
  presaleAddress,
  PRESALE_PROGRAM_ID
);
```

The client caches the presale account, mint accounts, and Token 2022 transfer-hook remaining-account metadata. Call `refetchState()` before building transactions when your UI may be using stale state.

## Program IDs

| Constant              | Value                                         |
| --------------------- | --------------------------------------------- |
| `PRESALE_PROGRAM_ID`  | `presSVxnf9UU8jMxhgSMqaRwNiT36qeBdNeTRKjTdbj` |
| `MEMO_PROGRAM_ID`     | `MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr` |
| `METAPLEX_PROGRAM_ID` | `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s` |

## Build A Transaction

```typescript theme={"system"}
import BN from "bn.js";

const tx = await presale.deposit({
  owner: wallet.publicKey,
  amount: new BN("500000000"),
});

// Sign, simulate, send, and confirm with your wallet or backend signer.
```

By default, the SDK estimates compute units and prepends a compute-budget instruction. Disable this behavior if your integration manages compute budget instructions itself:

```typescript theme={"system"}
presale.setComputeUnitOptimization(false);
```

## SDK Examples

<CardGroup cols={1}>
  <Card title="Presale Vault Examples" icon="code" iconType="solid" href="https://github.com/MeteoraAg/presale-sdk/tree/main/examples">
    Example scripts for initialization, deposits, claims, refunds, and creator actions.
  </Card>
</CardGroup>

## Testing The SDK

If you have cloned the SDK repository, start with package-level checks and tests:

```bash theme={"system"}
pnpm install
pnpm run build
pnpm test
```
