---
title: "@thru/programs"
description: Program-specific TypeScript bindings for Thru core programs.
source_url:
  html: https://thru.org/docs/sdks/web-packages/programs/
  md: https://thru.org/docs/sdks/web-packages/programs.md
---

# @thru/programs

`@thru/programs` contains program-specific bindings for built-in Thru programs. It is published as one package with subpath exports for each program surface.

## Install

```bash
npm install @thru/programs @thru/sdk
```

## Entry Points

| Import | What it provides |
| - | - |
| `@thru/programs/token` | Token program instruction builders, account parsers, address derivation, ABI builders, and formatting helpers. |
| `@thru/programs/passkey-manager` | Passkey-manager instruction encoders, challenge helpers, account-context builders, derivation helpers, account parsers, and P-256/WebAuthn encoding utilities. |

There is no root runtime import. Import from the program subpath you need.

## Token Program

Use `@thru/programs/token` when you are creating token mints, creating token accounts, transferring or minting tokens, parsing token account state, or formatting raw token amounts.

```ts
import {
  createTransferInstruction,
  deriveTokenAccountAddress,
  formatRawAmount,
  parseTokenAccountData,
} from "@thru/programs/token";

const destination = deriveTokenAccountAddress(
  ownerAddress,
  mintAddress,
  tokenProgramAddress
);

const instructionData = createTransferInstruction({
  sourceAccountBytes,
  destinationAccountBytes: destination.bytes,
  amount: 1_000_000n,
});

const parsed = parseTokenAccountData(account);
const displayAmount = formatRawAmount(parsed.amount, 6);
```

Important token exports include:

- `createInitializeMintInstruction`
- `createInitializeAccountInstruction`
- `createMintToInstruction`
- `createTransferInstruction`
- `deriveMintAddress`
- `deriveTokenAccountAddress`
- `deriveWalletSeed`
- `parseMintAccountData`
- `parseTokenAccountData`
- `formatRawAmount`

## Passkey Manager Program

Use `@thru/programs/passkey-manager` when you need to build passkey-managed wallet instructions, create validate challenges, derive wallet or credential lookup addresses, parse wallet state, or compose passkey-manager instruction bytes.

```ts
import {
  buildAccountContext,
  concatenateInstructions,
  createValidateChallenge,
  encodeTransferInstruction,
  encodeValidateInstruction,
} from "@thru/programs/passkey-manager";

const accountContext = buildAccountContext({
  feePayerAddress,
  walletAddress,
  readWriteAccounts: [destinationAddress],
});

const transfer = encodeTransferInstruction({
  accountContext,
  toAddress: destinationAddress,
  amount: 1_000_000n,
});

const challenge = createValidateChallenge({
  nonce,
  accountAddresses: accountContext.accountAddresses,
  instructionData: transfer,
});

const validate = encodeValidateInstruction({
  accountContext,
  authorityIndex,
  challenge,
  signature,
  authenticatorData,
  clientDataJSON,
});

const instructionData = concatenateInstructions(validate, transfer);
```

Important passkey-manager exports include:

- `encodeCreateInstruction`
- `encodeValidateInstruction`
- `encodeTransferInstruction`
- `encodeInvokeInstruction`
- `encodeAddAuthorityInstruction`
- `encodeRemoveAuthorityInstruction`
- `encodeRegisterCredentialInstruction`
- `createValidateChallenge`
- `deriveWalletAddress`
- `deriveCredentialLookupAddress`
- `buildAccountContext`
- `parseWalletNonce`
- `fetchWalletNonce`
- `parseWalletAuthorities`
- P-256 and byte/base64 helpers used by WebAuthn flows

## Related

- [Token Program](https://thru.org/docs/core-programs/token-program.md)
- [Passkey Manager Program](https://thru.org/docs/core-programs/passkey-manager-program.md)
- [`@thru/passkey`](https://thru.org/docs/sdks/web-packages/passkey.md)
- [`@thru/sdk`](https://thru.org/docs/sdks/web-packages/sdk.md)
