Skip to main content
A private account’s history is not visible on a block explorer. Every Cloak transaction posts a small encrypted record that only the account’s viewing key (nk) opens. scanTransactions reads the program’s transactions from your RPC, opens the records that belong to the key, and returns a history with amounts, fees and a running balance. The scan is read-only: it signs nothing and prompts nobody.

Get the viewing key

createCloak has no history call, so derive the account’s keys with the exported helpers. For a business-mode account you already hold the account key:
For an account opened from a wallet, the keys come from the wallet’s signature of CLOAK_ACCOUNT_MESSAGE, which costs the user one more signature:
This rebuilds the account the wallet opened from its own signature. It does not apply to a wallet that was linked to another account, or to an account opened with a Cloak Key or a stored key.
keys also contains the spending key. Keep only keys.viewingKeyNk and keys.owner.publicKey for history, and drop the rest.

Scan

Each ScannedTransaction has txType, amount, fee, netAmount and runningBalance (bigints in base units), mint, symbol, decimals, timestamp, recipient and signature. summary totals deposits, withdrawals and fees.

Scan incrementally

A full scan reads every program transaction, which is slow on a busy pool. Save lastSignature and pass it back as untilSignature next time to read only what is newer:
afterTimestamp and beforeTimestamp (milliseconds) bound a scan by time.

What a scan is not

scanTransactions produces history, not spendable notes. Two of its fields are the exception: deliveredNotes (notes others sent to this account) and recoveredDepositNotes (this account’s own deposits). Change from the account’s own spends cannot be rebuilt from a scan. See Notes and balances.