SDK Reference
Full reference for the @senddy/sdk TypeScript package.
Installation
npm install @senddy/sdk
# or
pnpm add @senddy/sdkCore SDK
SenddySDK
The main SDK class for interacting with the Senddy pool contract.
import { SenddySDK } from '@senddy/sdk';
const sdk = new SenddySDK();Key methods:
| Method | Description |
|---|---|
deposit() | Deposit USDC into the pool |
depositBatch() | Batch multiple deposits |
depositWithPermit2Sig() | Deposit using Permit2 signature |
depositWithEIP3009() | Deposit using EIP-3009 authorization |
quoteDepositShares() | Get shares for a deposit amount |
quoteWithdrawAssets() | Get assets for a share amount |
getIndex() | Get current Merkle tree index |
getNullifierAccumulator() | Get current nullifier accumulator |
getAssetConfig() | Get asset configuration |
depositInfo() | Get deposit details |
generateDepositId() | Generate a deposit ID |
Proof Generation
proveShield
Generate a zero-knowledge proof to shield (privatize) a deposit.
import { proveShield } from '@senddy/sdk';
const proof = await proveShield({
// Shield circuit inputs
});proveSpend
Generate a zero-knowledge proof to spend (transfer or withdraw) private notes.
import { proveSpend } from '@senddy/sdk';
const proof = await proveSpend({
// Spend circuit inputs
});Attestor Client
createAttestorClient
Create a client to communicate with the Senddy attestor service.
import { createAttestorClient } from '@senddy/sdk';
const attestor = createAttestorClient({
url: process.env.ATTESTOR_URL,
});
// Request a shield attestation
const shieldAttestation = await attestor.attestShield(proof);
// Request a spend attestation
const spendAttestation = await attestor.attestSpend(proof);Address Utilities
import {
isValidSenddyAddress,
encodeSenddyAddress,
decodeSenddyAddress,
} from '@senddy/sdk';
// Validate
isValidSenddyAddress('senddy1abc...'); // true/false
// Encode public key to Senddy address
const address = encodeSenddyAddress(publicKeyBytes);
// Decode Senddy address to public key
const { publicKey } = decodeSenddyAddress('senddy1abc...');Account Abstraction
Helpers for encoding calldata for smart wallet transactions:
import {
encodePoolV3DepositWithPermit2Calldata,
encodePoolV3SpendCalldata,
} from '@senddy/sdk';
// Encode a deposit with Permit2
const depositCalldata = encodePoolV3DepositWithPermit2Calldata({
amount,
permit2Signature,
permitData,
});
// Encode a spend transaction
const spendCalldata = encodePoolV3SpendCalldata({
proof,
publicInputs,
});Sync Engine
The sync engine monitors the blockchain for new commitments and nullifiers relevant to your keys.
import { SyncEngine, TachyonSyncEngine } from '@senddy/sdk';
// Standard sync
const sync = new SyncEngine({ /* options */ });
// Tachyon sync — O(1) spent detection via precomputed nullifiers
const tachyon = new TachyonSyncEngine({ /* options */ });Solana Bridge
import { CCTPBridge } from '@senddy/sdk';
const bridge = new CCTPBridge({
// CCTP configuration
});Graph Client
Query the Senddy subgraph for on-chain data:
import { Subgraph } from '@senddy/sdk';
const graph = new Subgraph();
// Query recent commitments, nullifiers, pool state, etc.Contract Addresses
import { SHARED_CONTRACTS, V3_CONTRACTS } from '@senddy/sdk';
// Access deployed contract addresses
console.log(V3_CONTRACTS.pool); // Pool contract
console.log(V3_CONTRACTS.verifier); // Verifier contractKey Derivation
import { deriveKeysWithEIP712 } from '@senddy/sdk';
// Derive Senddy keys from an EIP-712 signature
const keys = await deriveKeysWithEIP712(signer);Memo Encryption
import {
encodeMemoEnvelopeV4_1,
tryDecryptAsReceiverUnified,
} from '@senddy/sdk';
// Encrypt a memo for a recipient
const envelope = encodeMemoEnvelopeV4_1(memo, recipientPubKey);
// Decrypt a received memo
const memo = tryDecryptAsReceiverUnified(envelope, myPrivateKey);