Skip to main content

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

ModuleDescription
PacketClientMain entry point — loads and creates all entities
PacketWalletWallet adapter for keypairs and browser wallets
UserClientOn-chain user profile (display name, metadata URI)
KeyClientPublic encryption key registry — lets others encrypt messages to you
InboxClientReceive threads, enforce payment rules, browse conversation list
ThreadClientOpen threads, send messages, manage escrow
MessageClientLoad individual messages and resolve their content
RoomAdminClientCreate encrypted group rooms, manage membership, rotate keys
RoomClientMember side of rooms — recover epoch keys, read and send group messages
ActivityClientVirtual inbox — loads all threads a wallet has sent or received
client.messageEventsReal-time WebSocket subscriptions for incoming/outgoing messages
client.cryptoEnd-to-end encryption and decryption