Skip to main content

PacketWallet

PacketWallet is the wallet abstraction used by the SDK. It normalizes keypairs and browser wallet adapters (Phantom, WalletConnect, etc.) into a single interface.

Static Methods

PacketWallet.fromKeypair(keypair)

Creates a wallet from a Solana Keypair. Use this in scripts, tests, or server-side code.

import { PacketWallet } from "xpkt-sdk";
import { Keypair } from "@solana/web3.js";

const keypair = Keypair.generate();
const wallet = PacketWallet.fromKeypair(keypair);
ParameterTypeDescription
keypairKeypairA @solana/web3.js Keypair

Returns PacketWallet


PacketWallet.fromAdapter(adapter)

Creates a wallet from a browser wallet adapter. The adapter must expose publicKey, signTransaction, and signAllTransactions.

import { PacketWallet } from "xpkt-sdk";

// adapter from @solana/wallet-adapter-react or similar
const wallet = PacketWallet.fromAdapter(phantomWallet);
ParameterTypeDescription
adapter.publicKeyPublicKey | string | (() => PublicKey | string)Wallet public key
adapter.signTransaction(tx: Transaction | VersionedTransaction) => Promise<...>Signs a single transaction
adapter.signAllTransactions(txs: (Transaction | VersionedTransaction)[]) => Promise<...>Signs multiple transactions

Returns PacketWallet


PacketWallet.fromPublicKey(publicKey)

Creates a read-only wallet from a public key. Useful for fetching data on behalf of another user without signing.

const wallet = PacketWallet.fromPublicKey(somePublicKey);
ParameterTypeDescription
publicKeyPublicKey | stringThe wallet's public key

Returns PacketWallet


Properties

PropertyTypeDescription
publicKeyPublicKeyThe wallet's public key
kind"keypair" | "adapter"How the wallet was constructed
signTransaction(tx: Transaction | VersionedTransaction) => Promise<...>Signs a transaction
signAllTransactions(txs: ...[]) => Promise<...[]>Signs multiple transactions