Constants & PDAs
Exported constants and PDA derivation functions.
Constants
import {
PACKET_PROGRAM_ID,
PACKET_LOOK_UP_TABLE,
WSOL_ID,
SYSTEM_PROGRAM_ID,
TOKEN_PROGRAM_ID,
TOKEN_2022_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID,
NO_INBOX,
SEEDS,
TokenProgramTypeToProgramId,
} from "xpkt-sdk";
| Constant | Type | Description |
|---|---|---|
PACKET_PROGRAM_ID | PublicKey | On-chain program address |
PACKET_LOOK_UP_TABLE | PublicKey | Address lookup table used in transactions |
WSOL_ID | PublicKey | Wrapped SOL mint address |
SYSTEM_PROGRAM_ID | PublicKey | Solana system program |
TOKEN_PROGRAM_ID | PublicKey | SPL Token program |
TOKEN_2022_PROGRAM_ID | PublicKey | Token-2022 program |
ASSOCIATED_TOKEN_PROGRAM_ID | PublicKey | Associated Token Account program |
NO_INBOX | BN | Sentinel value indicating a thread has no associated inbox |
TokenProgramTypeToProgramId | Record<TokenProgramType, PublicKey> | Maps TokenProgramType enum to program address |
SEEDS
PDA seed strings used by the program.
const SEEDS = {
user: "user",
inbox: "inbox",
inboxBody: "inbox_body",
inboxMetadata: "inbox-metadata",
inboxArchive: "inbox_archive",
thread: "thread",
message: "msg",
vault: "packet_vault",
key: "key",
};
PDAs
All PDA derivation functions are available on the PacketPDAs export:
import { PacketPDAs } from "xpkt-sdk";
| Method | Parameters | Description |
|---|---|---|
PacketPDAs.user(owner, programId?) | PublicKey | User account PDA |
PacketPDAs.inbox(id, owner, programId?) | BN, PublicKey | Inbox PDA |
PacketPDAs.inboxBody(inbox, programId?) | PublicKey | Inbox body (live page) PDA |
PacketPDAs.inboxMetadata(inbox, programId?) | PublicKey | Inbox metadata PDA |
PacketPDAs.thread(threadId, programId?) | number | Thread PDA |
PacketPDAs.message(threadId, msgSeq, programId?) | number, number | Message PDA |
PacketPDAs.vault(programId?) | — | Protocol vault PDA |
PacketPDAs.key(owner, programId?) | PublicKey | User key account PDA |
PacketPDAs.ata(mint, owner, tokenProgram?) | PublicKey, PublicKey | Associated token account address |
Example
import { PacketPDAs, BN } from "xpkt-sdk";
const inboxAddress = PacketPDAs.inbox(new BN(1), ownerPublicKey);
const threadAddress = PacketPDAs.thread(42);
const messageAddress = PacketPDAs.message(42, 1);
const ata = PacketPDAs.ata(usdcMint, ownerPublicKey);
programId defaults to PACKET_PROGRAM_ID in all functions and can be omitted unless you're targeting a custom deployment.