@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
Section titled “Install”npm install @thru/programs @thru/sdkEntry Points
Section titled “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
Section titled “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.
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:
createInitializeMintInstructioncreateInitializeAccountInstructioncreateMintToInstructioncreateTransferInstructionderiveMintAddressderiveTokenAccountAddressderiveWalletSeedparseMintAccountDataparseTokenAccountDataformatRawAmount
Passkey Manager Program
Section titled “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.
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:
encodeCreateInstructionencodeValidateInstructionencodeTransferInstructionencodeInvokeInstructionencodeAddAuthorityInstructionencodeRemoveAuthorityInstructionencodeRegisterCredentialInstructioncreateValidateChallengederiveWalletAddressderiveCredentialLookupAddressbuildAccountContextparseWalletNoncefetchWalletNonceparseWalletAuthorities- P-256 and byte/base64 helpers used by WebAuthn flows