SDK
Integrate confidential payments with a small JavaScript surface. The demo wallet uses the same Supabase backed ledger API documented below.
Installation
npm install @shildo/sdk
# or
pnpm add @shildo/sdk
Quick start
import { createShildoClient } from "@shildo/sdk";
const shildo = createShildoClient({
network: "base-sepolia",
apiKey: process.env.SHILDO_API_KEY,
});
const intent = await shildo.createIntent({
asset: "USDC",
amount: "100.00",
recipient: "0xabc1234567890123456789012345678901234567890",
shielded: true,
memo: "Invoice 1042",
});
const receipt = await shildo.submitIntent(intent);
console.log(receipt.txHash, receipt.blockNumber);
Client configuration
| Option | Type | Description |
|---|---|---|
network | string | base, base-sepolia, ethereum, solana-devnet |
apiKey | string | Server side prover API key |
rpcUrl | string | Optional custom Base RPC |
timeoutMs | number | Proof submission timeout (default 30000) |
Demo wallet Supabase API
The open source wallet at /access calls Supabase RPC functions directly through access-db.js. You can replicate this pattern for prototypes.
register_wallet
const { data, error } = await supabase.rpc("register_wallet", {
p_address: "0x...",
p_seed_hash: sha256Hex(normalizedSeedPhrase),
});
// Returns { id, address }
// Credits 5 ETH, 1000 USDC, 1000 SHILDO, 1 BTC
// Writes 4 is_credit transactions from treasury
process_transfer
const { data, error } = await supabase.rpc("process_transfer", {
p_from_address: sender,
p_to_address: recipient,
p_asset: "usdc",
p_amount: 25.5,
p_memo: "Payment for services",
p_is_shielded: true,
});
// Returns { id, tx_hash, block_number, is_shielded }
Validation rules
- Addresses must match
^0x[a-f0-9]{40}$ - Asset must be eth, usdc, shld, or btc
- Amount must be positive
- Sender and recipient must differ
- Sender balance must cover amount
Database schema (demo)
| Table | Purpose |
|---|---|
wallets | Registered addresses and seed hashes |
balances | Per wallet asset amounts |
transactions | Public ledger rows with shield flag |
chain_state | Simulated latest block counter |
Run supabase/schema.sql in the Supabase SQL editor to initialize. See the wallet banner if schema is missing.
Shield flag
Set shielded: true in SDK calls or p_is_shielded: true in RPC calls. The ledger stores is_shielded on the transaction row and moves memos into shielded_memo when shielded.
Events (production SDK)
shildo.on("intent.sealed", (e) => { /* commitment id */ });
shildo.on("proof.verified", (e) => { /* tx hash on Base */ });
shildo.on("delivery.completed", (e) => { /* destination tx */ });
shildo.on("delivery.failed", (e) => { /* retry or refund */ });
Error codes
| Code | Meaning |
|---|---|
INSUFFICIENT_BALANCE | Sender lacks asset amount |
INVALID_RECIPIENT | Malformed address |
PROOF_REJECTED | Verifier reverted on Base |
ROUTE_UNAVAILABLE | No relayer liquidity for path |