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 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

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
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