Introduction
Packet is a Solana-native messaging protocol with built-in end-to-end encryption, payment gating, and escrow. This SDK gives you everything you need to interact with the protocol from TypeScript.
Install
npm install xpkt-sdk
Quick Start
import { PacketClient, PacketWallet } from "xpkt-sdk";
import { Connection, Keypair } from "@solana/web3.js";
const connection = new Connection("photon-or-helius-rpc");
const keypair = Keypair.generate();
const client = new PacketClient({
wallet: PacketWallet.fromKeypair(keypair),
connection,
});
// Set up end-to-end encryption
client.useSolanaCryptoKeypair(keypair);
// Create an inbox
const { client: inbox } = await client.createInbox({ inboxId: 1 });
// Create a thread to another user
const { client: thread } = await client.createThread({
to: recipientPublicKey,
messageType: MessageType.Text,
content: "Hello!",
});
What's in the SDK
| Module | Description |
|---|---|
PacketClient | Main entry point — loads and creates all entities |
PacketWallet | Wallet adapter for keypairs and browser wallets |
UserClient | On-chain user profile (display name, metadata URI) |
KeyClient | Public encryption key registry — lets others encrypt messages to you |
InboxClient | Receive threads, enforce payment rules, browse conversation list |
ThreadClient | Open threads, send messages, manage escrow |
MessageClient | Load individual messages and resolve their content |
ActivityClient | Virtual inbox — loads all threads a wallet has sent or received |
client.messageEvents | Real-time WebSocket subscriptions for incoming/outgoing messages |
client.crypto | End-to-end encryption and decryption |