LDGR/Docs
DocsDevelopersSDKs & integrations

Build without taking custody.

Use the terminal CLI for your own local wallet, the wallet SDK for a person’s explicit confirmation, and the client SDK for your service’s reads, verification, and caller-owned signing.

Choose the narrowest package for the job.

@ldgr/mcp
For AI clients: read ledger and Explorer data, open faucet links, and prepare unsigned wallet requests. Choose local npm or hosted Streamable HTTP in the MCP setup guide. Signing requires user-run local CLI approval.
@ldgr/cli
For an individual’s self-custody terminal wallet: create or import local wallets, inspect balances, send assets, and switch between mainnet and testnet. It is not a backend signer or a replacement for a website’s explicit wallet confirmation.
@ldgr/wallet-sdk
For browser apps that offer the Ledra Wallet extension and Ledra Connect QR scanning, then request explicit user confirmation for sends, swaps, contracts, names, and object writes.
@ldgr/client
For backends and trading systems that read ledger state, request AMM quotes, inspect public objects and usernames, verify payments, and send assets from caller-owned service wallets.
@ldgr/protocol
For canonical payload types, exact amount helpers, address tools, and cryptographic primitives when you are building a signer or advanced integration.
@ldgr/wallet-core
For wallet surfaces that need browser-safe self-custody primitives: passkey and recovery-key vaults, in-memory signing, and canonical transfer or subscription-lock builders. Your app provides persistence; the package never chooses a vault store.

Terminal wallet: create and back up locally.

Install the CLI when you want to manage your own wallet from a terminal. It keeps the wallet store on your machine; the service never receives the recovery key or passphrase.

Code example
npm install -g @ldgr/cli
ldgr wallet create
ldgr address
ldgr balance
ldgr wallet export ~/ldgr-recovery-key.txt

The default wallet store is ~/.ldgr/wallet.json and is owner-only. Creation and import offer optional passphrase protection; unprotected wallets rely on that local-file boundary. The CLI never accepts recovery keys or passphrases as command arguments or environment variables. Keep the exported recovery-key file offline: anyone who has it can control the wallet.

Website: offer Ledra Connect and ask the wallet to confirm.

Install the browser SDK in your app bundle. Its unified widget uses the extension on the same device or Ledra Connect for an encrypted QR session with the Web Wallet. The wallet keeps the private key and shows each request for the user to review.

Code example
npm install @ldgr/wallet-sdk

Wallet surfaces: keep custody local.

Use the shared wallet core when you are building a wallet UI or another self-custody surface. It keeps passkey or recovery-key material local, derives signing authority only in memory, and builds canonical submissions without choosing your persistence layer.

Code example
npm install @ldgr/wallet-core

Code example
import { createLdgrWallet, type LdgrWalletProvider } from "@ldgr/wallet-sdk";

const provider = (window as Window & { ldgr?: LdgrWalletProvider }).ldgr;
const wallet = createLdgrWallet(provider);

await wallet.connect({ network: "testnet" }); // also accepts 0 / 1
const receipt = await wallet.sendNative({
  to: merchantAddress,
  amount: "2.50",
  memo: "Order 1234",
});

console.log(receipt.transactionHash);

Backend: verify before fulfilment.

Record the expected order terms before payment. Treat a client receipt as a hint; only fulfil after the transaction hash is verified against the authoritative ledger.

Code example
npm install @ldgr/client @ldgr/protocol

Code example
import { createLdgrClient, generateLocalWallet, loadLocalWallet } from "@ldgr/client";
import { nativeAssetDefinitionForLedger, parseDecimalAmount } from "@ldgr/protocol";

const client = createLdgrClient({ network: "testnet" });
const payment = await client.payments.verifyTransfer(transactionHash, {
  to: merchantAddress,
  asset: "t0",
  amount: "2.50",
});

if (payment.status === "confirmed") {
  await fulfilOnce(payment.transactionHash);
}

// Provision once: write recoveryKey directly to your secret manager.
const created = await generateLocalWallet({ ledgerId: 0 });
await secretStore.writeOnce("ldgr-service-wallet", created.recoveryKey);

// On startup, recreate the same service signer.
const serviceWallet = await loadLocalWallet({
  ledgerId: 0,
  recoveryKey: await secretStore.read("ldgr-service-wallet"),
});
const atomicAmount = parseDecimalAmount("2.50", nativeAssetDefinitionForLedger(0));

Use t0 on testnet and t1 on mainnet for SDK inputs. A recovery key controls the service wallet: keep it only in a secret manager or HSM, and never generate, request, or store a customer’s private key on your backend.

Backend: send from a caller-owned service wallet.

The client selects the ledger endpoint from the network, resolves native or user-issued asset metadata, fetches the next nonce, signs the transfer, and submits it to the canonical transfer endpoint. It retries once when another process wins the nonce race.

Code example
import { LEDRA_TESTNET_ASSET_ID } from "@ldgr/protocol";

const result = await client.transfers.send({
  wallet: serviceWallet,
  asset: LEDRA_TESTNET_ASSET_ID, // use LEDRA_MAINNET_ASSET_ID on mainnet, or a user-token code
  amount: "2.50",
  to: recipientAddress,
  memo: "Order 1234",
});

if (result.status === "settled") {
  console.log("Settled", result.transactionHash);
  console.log("Fee", result.fee, result.feeAsset);
} else {
  console.error("Transfer rejected", result.code, result.error);
}

A settled result includes the transaction hash and the ledger-computed fee. A settlement failure returns status: "failed" with the error and stable code; it has no hash or fee because the ledger rejected it before appending a transaction. Unexpected transport failures still throw and should be retried according to the service’s delivery policy.

Read markets, public data, and subscriptions.

Code example
const quote = await client.amm.quoteRoute(assetIn, assetOut, "10.00", 3);
const profile = await client.objects.getByKey("myapp.profiles", accountAddress);
const username = await client.usernames.getPrimary(accountAddress);
const entitlement = await client.subscriptions.getEntitlement({
  payer: accountAddress,
  planId,
});

Quotes are estimates, not settlement promises. Re-quote immediately before signing and protect a swap with an explicit minimum output. Subscription entitlement is a read for access control; it never authorizes an automatic debit.

Keep authority clear

User money moves through the extension’s explicit confirmation. A backend may use a caller-owned service signer, but it must not become a hidden signing path for customer funds.

Add-ons

Ledra Memory is a separate service built on the LDGR ledger. It provides encrypted project memory for agents, with scoped access and prepaid service credit. It is currently a testnet preview.

Explore Ledra Memory → · Set up the service →