Dilithia Browser SDK¶
The Dilithia Browser SDK (@dilithia/browser-sdk) lets you build decentralized applications that integrate with the Dilithia Wallet Chrome extension.
Two-Layer Architecture¶
The SDK is organized into two layers:
| Layer | Purpose | Requires Wallet? |
|---|---|---|
| Wallet (Layer 1) | Signing, transactions, shielded pool operations | Yes |
| ChainClient (Layer 2) | Read-only RPC queries, balances, receipts, simulations | No |
Wallet functions call through the browser extension and require user approval for sensitive operations like signing and sending transactions.
ChainClient talks directly to a Dilithia RPC node and needs no wallet -- pass any rpcUrl and start querying.
Install¶
Quick Start¶
import {
hasDilithiaProvider,
connect,
createChainClient,
transfer,
} from "@dilithia/browser-sdk";
// 1. Detect the wallet extension
if (!hasDilithiaProvider()) {
throw new Error("Please install the Dilithia Wallet extension.");
}
// 2. Connect to the wallet
const session = await connect(["dilithia_signPayload"]);
console.log("Connected:", session.address, "on chain", session.chainId);
// 3. Create a chain client for read-only queries
const chain = createChainClient(session.rpcUrl);
// 4. Check balance
const { balance } = await chain.getBalance(session.address);
console.log("Balance:", balance, "DILI");
// 5. Transfer tokens
const tx = await transfer("dili1recipient", 50);
console.log("Submitted:", tx.txHash);
// 6. Wait for confirmation
const receipt = await chain.waitForReceipt(tx.txHash);
console.log("Confirmed at block", receipt.blockHeight, "| status:", receipt.status);
API Reference¶
- Wallet (Layer 1) -- Provider detection, connection, signing, transactions, events, shielded pool
- ChainClient (Layer 2) -- Balance, nonce, network info, contract queries, gas estimation, receipts
- Types -- All exported TypeScript types
Guides¶
- Getting Started -- Step-by-step walkthrough
- Gas Sponsor (Paymaster) -- Let a sponsor contract pay gas fees for your users
- Shielded Pool -- Private deposits, withdrawals, and compliance proofs