SDK Reference

sdk.privateSend()

typescript
await sdk.privateSend(
  tokenAddress,        // string
  amount,              // bigint
  receiverPubkey       // bigint — recipient's spending pubkey
);

Selects up to two unspent notes from NoteManager, generates a spend proof, and submits the transaction. Two new commitments are inserted on-chain — one for the recipient, one as change. No tokens move; no on-chain data links sender to recipient.

If zeroGStorage is configured, the SDK automatically encrypts the recipient's note hint ({ amount, salt, commitment }) and uploads it to 0G Storage after the spend confirms. The recipient's next sync() call discovers and decrypts it — no manual communication needed.

The recipient must share their spending pubkey with you once (e.g. via a QR code or a message). All future sends to that pubkey are then fully automatic via 0G Storage hints.

Deriving a spending pubkey

typescript
import { deriveSpendingPubkey } from "stealthpay-sdk";

const pubkey = deriveSpendingPubkey(spendingPrivkey); // bigint → bigint