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

# TypeScript Quickstart

> Get started with Privacy Boost in TypeScript in 5 minutes

# TypeScript Quickstart

Build a private payment flow in your web app with the TypeScript SDK.

<Info>
  This quickstart gets you running in 5 minutes with minimal explanation. For detailed walkthroughs of each step, see the [TypeScript Getting Started guide](/sdk/typescript/getting-started). For background on configuration and auth options, see [Setup](/sdk/concepts/app-setup).
</Info>

## Installation

```bash theme={null}
npm install @sunnyside-io/privacy-boost
# or
yarn add @sunnyside-io/privacy-boost
# or
pnpm add @sunnyside-io/privacy-boost
```

## Quick Example

```typescript theme={null}
import { PrivacyBoost } from '@sunnyside-io/privacy-boost';
import { createWalletAdapter } from '@sunnyside-io/privacy-boost-react';

// 1. Initialize SDK
const sdk = await PrivacyBoost.create({
  serverUrl: 'https://optimism.sepolia.privacyboost.io',
  wethContractAddress: "0x4200000000000000000000000000000000000006",
  appId: 'app_abc123xyz',
});

// 2. Authenticate (keySource is optional; defaults to walletDerived when no persistence)
const adapter = createWalletAdapter();
const authResult = await sdk.auth.authenticate(adapter);
// Or with a specific key source:
// const authResult = await sdk.auth.authenticate(adapter, { keySource: { type: 'mnemonic', phrase: '...' } });

if (authResult.status === 'authenticated') {
  console.log('Your privacy address:', authResult.privacyAddress);
}
```

<Info>
  **When does `credentialRequired` fire?**
  `credentialRequired` only fires when persistence with `pin` or `password` unlock is configured. For the simple case (no persistence), `authenticate()` always returns `authenticated` directly.
</Info>

```typescript theme={null}
// 3. Check balance
const balance = await sdk.vault.getBalance('0x...token-address');
console.log('Shielded balance:', balance);

// 4. Deposit tokens
const shieldResult = await sdk.vault.shield({
  tokenAddress: '0x...token-address',
  amount: 1000000000000000000n, // 1 token (18 decimals)
});
console.log('Deposit tx:', shieldResult.txHash);

// 5. Send privately
const sendResult = await sdk.vault.send({
  to: '0x04...recipient-privacy-address',
  tokenAddress: '0x...token-address',
  amount: 500000000000000000n, // 0.5 tokens
});
// send() and unshield() return a local placeholder txHash; track the
// real on-chain settlement by requestId instead.
const transfer = await sdk.transactions.getTransferStatus(sendResult.requestId);
console.log('Transfer status:', transfer.status);

// 6. Withdraw to any address
const unshieldResult = await sdk.vault.unshield({
  tokenAddress: '0x...token-address',
  amount: 250000000000000000n, // 0.25 tokens
  recipientAddress: '0x...recipient-address',
});
const withdrawal = await sdk.transactions.getUnshieldStatus(unshieldResult.requestId);
console.log('Withdraw status:', withdrawal.status);
```

<Info>
  For `send()` and `unshield()`, the returned `txHash` is a **client-side placeholder** until the canonical on-chain hash is available — poll by `requestId` (`sdk.transactions.getTransferStatus` / `getUnshieldStatus`). For `shield()`, `txHash` is the real on-chain hash because the wallet signs and submits it directly.
</Info>

## Progress Tracking

Track operation progress with callbacks:

```typescript theme={null}
await sdk.vault.shield({
  tokenAddress: '0x...',
  amount: 1000000000000000000n,
  onProgress: ({ step, message, txHash }) => {
    console.log(`Step: ${step}, Message: ${message}`);
    if (txHash) console.log(`Tx: ${txHash}`);
  },
});
```

## Next Steps

<CardGroup cols={2}>
  <Card title="TypeScript Getting Started" href="/sdk/typescript/getting-started">
    Detailed walkthrough of each integration step
  </Card>

  <Card title="Setup Guide" href="/sdk/concepts/app-setup">
    App ID, configuration, and auth method selection
  </Card>

  <Card title="Deposits Guide" href="/sdk/typescript/guides/deposits">
    Deposits, withdrawals, transfers, and balance queries
  </Card>

  <Card title="API Reference" href="/sdk/typescript/api-reference">
    Complete method signatures and type definitions
  </Card>
</CardGroup>
