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 rpc = "https://devnet.helius-rpc.com/?api-key=YOUR_KEY";
const connection = new Connection(rpc);
const keypair = Keypair.generate();
const client = new PacketClient({
wallet: PacketWallet.fromKeypair(keypair),
connection,
photonRpc: {
compressionApiEndpoint: rpc,
proverEndpoint: rpc,
},
cluster: "devnet",
});
// 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!",
});
Packet requires a ZK Compression / Photon-compatible RPC. Helius RPC is recommended; a standard-only Solana RPC will not work.
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 |
RoomAdminClient | Create encrypted group rooms, manage membership, rotate keys |
RoomClient | Member side of rooms — recover epoch keys, read and send group messages |
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 |