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

# TypeScript SDK

> The browser SDK package path and what remains before public npm release.

Vaulkyrie has TypeScript SDK code in the browser wallet and a package workspace at `packages/vaulkyrie-sdk`. The package is named `@vaulkyrie/sdk` and is prepared for local builds, local packing, and eventual npm publication.

<Warning>
  Until the package is published and versioned on npm, use local workspace linking or local package tarballs only. Do not treat `npm install @vaulkyrie/sdk` as a live public install path until the npm package exists.
</Warning>

## Current exports

`packages/vaulkyrie-sdk/src/index.ts` exports:

* `constants`
* `types`
* `pda`
* `instructions`
* `accounts`
* `errors`
* `VaulkyrieClient`

## What it can do today

| Capability            | Source                                        |
| --------------------- | --------------------------------------------- |
| PDA derivation        | `packages/vaulkyrie-sdk/src/pda.ts`           |
| Instruction builders  | `packages/vaulkyrie-sdk/src/instructions.ts`  |
| Account decoders      | `packages/vaulkyrie-sdk/src/accounts.ts`      |
| Error parsing         | `packages/vaulkyrie-sdk/src/errors.ts`        |
| Account fetch helpers | `packages/vaulkyrie-sdk/src/client.ts`        |
| Spend binding hashes  | `packages/vaulkyrie-sdk/src/spendBindings.ts` |

## Builder coverage

The internal TS SDK currently includes builders for:

* `createInitVaultInstruction`
* `createInitAuthorityInstruction`
* `createInitPqcWalletInstruction`
* `createAdvancePqcWalletInstruction`
* `createSetVaultStatusInstruction`
* `createInitSpendOrchestrationInstruction`
* `createCommitSpendOrchestrationInstruction`
* `createCompleteSpendOrchestrationInstruction`
* `createInitRecoveryInstruction`
* `createCompleteRecoveryInstruction`

It does not yet expose every Rust SDK builder. Missing public TS builders include authority proof chunking, staged authority rotation, winter authority advance, quantum vault split/close, spend failure, and authority migration.

## Example: fetch a vault registry

```ts theme={null}
import { Connection, PublicKey } from "@solana/web3.js";
import { VaulkyrieClient } from "@vaulkyrie/sdk";

const connection = new Connection("https://api.devnet.solana.com", "confirmed");
const client = new VaulkyrieClient(connection);

const vault = await client.getVaultRegistry(new PublicKey(walletPublicKey));
```

## Example: initialize a PQC wallet instruction

```ts theme={null}
import { PublicKey } from "@solana/web3.js";
import { createInitPqcWalletInstruction } from "@vaulkyrie/sdk";

const ix = createInitPqcWalletInstruction(
  new PublicKey(payer),
  new PublicKey(pqcWalletPda),
  {
    walletId,
    currentRoot,
    bump,
  },
);
```

## Example: build spend orchestration bindings

```ts theme={null}
import {
  buildSpendActionHash,
  buildSpendOrchestrationBindings,
  generateSpendSessionNonce,
} from "@vaulkyrie/sdk/spendBindings";

const sessionNonce = generateSpendSessionNonce();
const actionHash = await buildSpendActionHash({
  vaultId,
  recipient,
  amountAtomic: "1000000",
  tokenSymbol: "SOL",
  tokenMint: null,
  sessionNonce,
});

const bindings = await buildSpendOrchestrationBindings({
  actionHash,
  messageBytes,
  signerIds: [1, 2],
  threshold: 2,
  participantCount: 3,
  expirySlot: 123456n,
});
```

## How developers will use it after publication

Once published to npm, the intended install command is:

```bash theme={null}
npm install @vaulkyrie/sdk @solana/web3.js
```

Example import:

```ts theme={null}
import { VaulkyrieClient, findPqcWalletPda } from "@vaulkyrie/sdk";
```

Before publication, local development can build and pack the workspace package:

```bash theme={null}
npm install
npm run build:sdk
npm run pack:sdk
```

Then consume the generated local tarball or use a workspace dependency in a test application.

## Should Vaulkyrie create a standalone TypeScript SDK?

Yes, if external developers are expected to integrate Vaulkyrie into their own codebases.

Yes. The package folder now exists, but it should not be promoted as public-ready until builder parity, byte-level fixture tests, and npm release metadata are complete.

Required implementation steps:

1. Keep extension-independent SDK code in `packages/vaulkyrie-sdk`.
2. Add fixtures that compare TypeScript instruction bytes against `crates/vaulkyrie-sdk`.
3. Close builder parity gaps with the Rust SDK.
4. Confirm package contents with `npm pack -w @vaulkyrie/sdk --dry-run`.
5. Reserve or configure the `@vaulkyrie` npm organization.
6. Publish only after tests and release review pass.

## Current readiness

| Question                         | Answer                                                                                                  |
| -------------------------------- | ------------------------------------------------------------------------------------------------------- |
| Is there TS SDK code?            | Yes, in `packages/vaulkyrie-sdk` and mirrored in the extension source.                                  |
| Is it published as npm package?  | Not yet. It is package-ready for local build/pack testing.                                              |
| Is it complete against Rust SDK? | No. It covers the browser's current needs, not every builder.                                           |
| Can docs include snippets?       | Yes, but npm install snippets should remain marked as future/public-release examples until publication. |
