SDKCore release 0.1.0

Getting started

Create the SDK client with a real Solana connection and wallet adapter, then read a pool and request an exact CPMM quote.

The SDK is Node.js-first and uses bigint for amounts, indices and counters. The following example creates a wallet-backed public client and gets an advisory A→B quote from a configured Devnet pool.

src/client.ts
import {
  Connection,
  Keypair,
  PublicKey,
  Transaction,
  VersionedTransaction,
} from "@solana/web3.js";
import { Lethenymous } from "@lethenymous/sdk";
 
const encodedKey = process.env.DEVNET_KEYPAIR_JSON;
if (!encodedKey) throw new Error("DEVNET_KEYPAIR_JSON is required");
const keypair = Keypair.fromSecretKey(
  Uint8Array.from(JSON.parse(encodedKey) as number[]),
);
 
const connection = new Connection(
  process.env.SOLANA_RPC_URL ?? "https://api.devnet.solana.com",
  "finalized",
);
const lookupTableAddress = process.env.LETHENYMOUS_LOOKUP_TABLE;
if (!lookupTableAddress) throw new Error("LETHENYMOUS_LOOKUP_TABLE is required for private operations");
const wallet = {
  publicKey: keypair.publicKey,
  async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
    transaction.partialSign(keypair);
    return transaction;
  },
  async signVersionedTransaction(
    transaction: VersionedTransaction,
  ): Promise<VersionedTransaction> {
    transaction.sign([keypair]);
    return transaction;
  },
};
 
const sdk = new Lethenymous({
  connection,
  wallet,
  lookupTables: [new PublicKey(lookupTableAddress)],
});
const pool = new PublicKey(process.env.POOL_ADDRESS!);
const quote = await sdk.quote(pool, "AToB", 1_000_000n);
console.log(`Quoted output in base units: ${quote}`);

The wallet adapter example is for a local Devnet integration. Do not put a funded wallet secret in source control, logs or an untrusted service. A production application should bind this interface to its wallet custody model.

Private operations

Before Private Swap or Unshield, configure all of the following:

  1. A persistent encrypted NoteStore.
  2. The production prover executable and exact circuit PK files.
  3. A validated v0 address lookup table.
  4. A validated v0 lookup table address in LETHENYMOUS_LOOKUP_TABLE and a wallet adapter implementing signVersionedTransaction.
src/shielded-wallet.ts
import {
  EncryptedFileNoteStore,
  ProductionProver,
  keyHierarchy,
  ownerCommitment,
} from "@lethenymous/sdk";
 
const seed = Uint8Array.from(Buffer.from(process.env.WALLET_SEED_HEX!, "hex"));
const spendSecret = keyHierarchy(seed).spendSecret;
const owner = ownerCommitment(spendSecret);
const noteStore = EncryptedFileNoteStore.fromSeed(
  process.env.NOTE_STORE_PATH ?? "./.lethenymous/notes.lnsj",
  seed,
  owner,
);
const prover = new ProductionProver({
  executablePath: process.env.PRODUCTION_PROVER_PATH!,
  privateSwapPkPath: process.env.PRIVATE_SWAP_PK_PATH!,
  unshieldPkPath: process.env.UNSHIELD_PK_PATH!,
});
const shielded = sdk.shieldedWallet(seed, prover, { noteStore });

The example assumes the sdk, seed and environment are supplied by your Node application. The encrypted note journal contains spend-critical note randomness and pending operation preimages; secure it like the seed. See Notes & NoteStore, Prover integration and Recovery & witnesses.

PreviousInstallationNext Shield with the SDK
Source baseline: frozen Core v0.1.0 / SDK v0.1.1.