SDK Reference

sdk.sync()

typescript
// Replay all past events and subscribe to new ones
await sdk.sync(provider, fromBlock?);

// Access NoteManager directly
const notes = sdk.noteManager.getUnspentNotes(tokenAddress);
const root  = sdk.noteManager.getCurrentRoot();
const spent = sdk.noteManager.isNullifierSpent(nullifier);

Replays all Shielded and Spent events to rebuild the local Merkle tree. After the historical replay, the SDK subscribes to new events in real time.

Call once at startup. Subsequent shielding/spending operations automatically update the local tree.

Optional fromBlock

Pass a block number to skip re-processing older events. Useful if you persist the tree locally and only need to catch up on recent changes.