Overview
After tokens are deposited into the mixer, the depositor publishes an encrypted ciphertext on-chain addressed to the recipient’s X25519 key. To claim, the recipient must:- Fetch all ciphertexts from the indexer
- Attempt to decrypt each one using their X25519 private key
- Successfully decrypted ciphertexts are their claimable UTXOs
- Fetch the Merkle proof for each claimable UTXO
getFetchClaimableUtxosFunction handles all of these steps automatically.
Usage
Parameters
The zero-based index of the Merkle tree to scan. Start with
0 for the first tree. If the current tree is filling up, increment to check the next one.The leaf position to start scanning from (inclusive). Pass
0 to scan from the beginning. To resume from where you left off, pass the insertion index of the last UTXO you have already seen.The leaf position to stop at (inclusive). If omitted, scans to the end of the current tree. Use this to limit the scan range when you know the approximate insertion window of your UTXOs.
Return Value
ClaimableUtxoData is a flat structure containing both the UTXO data and its Merkle proof. These objects are passed directly to the claim functions — no destructuring needed.
Example: Fetch All UTXOs for Tree 0
Example: Paginated Scan
For large trees, scan in chunks to avoid timeouts:How Decryption Works
The SDK derives your X25519 private key from the master seed, then for each UTXO ciphertext:- Extracts the depositor’s ephemeral X25519 public key from the ciphertext header
- Computes an X25519 ECDH shared secret
- Derives an AES-GCM key from the shared secret
- Attempts to decrypt the 68-byte payload
- If decryption succeeds, checks the 12-byte domain separator to categorize the UTXO type
Error Handling
Fetching UTXOs involves two distinct infrastructure dependencies: the Umbra indexer (for ciphertext discovery) and the RPC node (for Merkle proof data). UseisFetchUtxosError from @umbra-privacy/sdk/errors and switch on err.stage to handle each failure point.
An empty result (
ephemeral: [], receiver: []) is not an error - it means no UTXOs addressed to you were found in that scan range. Errors are only thrown for infrastructure failures.Storing UTXO State
The SDK does not persist UTXO state between calls. If your application needs to track which UTXOs have been claimed, maintain your own list (keyed byinsertionIndex + treeIndex) and exclude already-claimed entries from future claims.
A claimed UTXO’s nullifier is burned on-chain - attempting to claim it again will fail at the on-chain program level.