SDK Reference

Initialization

typescript
import { StealthPaySDK } from "stealthpay-sdk";
import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider("https://evmrpc-testnet.0g.ai");
const signer   = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);

const sdk = new StealthPaySDK({
  signer,
  privacyPoolAddress: "0x87fECd1AfA436490e3230C8B0B5aD49dcC1283F1",
  spendingPrivkey: mySpendingPrivkey, // bigint — kept locally

  // Optional: enable 0G Storage hint layer so privateSend() auto-posts
  // encrypted notes and sync() auto-discovers received notes.
  zeroGStorage: {
    indexerRpc: "https://indexer-storage-testnet-standard.0g.ai",
  },
});

// Sync Merkle tree + scan 0G Storage for received note hints
await sdk.sync(provider);

Constructor options

OptionTypeDescription
signerSignerethers v6 Signer for sending transactions
privacyPoolAddressstringProxy contract address
spendingPrivkeybigintYour 32-byte spending key (never transmitted)
zeroGStorageobject (optional)Enable 0G Storage hint layer for auto note discovery
confirmTimeoutMsnumber (optional)Tx confirmation timeout in ms. Default 120 000
spendingPrivkey is a local secret. Do not log it, store it unencrypted, or pass it to any external service.