Skip to main content
  1. Read fetches encrypted Private Solana Token Accounts from the indexer with dedicated RPC methods.
  2. Only the user, or anyone the user authorizes, can decrypt balances with their viewing key.
  3. Use it after a private balance changes and before a transfer.
  1. getBalance returns public SOL. getAccount returns a public token account.
  2. The RPC returns the public balance.

Get Started

1

Prerequisites

The TypeScript examples require Node.js 24 or later, pnpm 11.18.0, and the Solana CLI.
Source: sdk-libs/ts
Add a Helius API key:
.env
The examples use the Solana CLI wallet as the payer by default. The payer must hold devnet SOL. See How to Get Devnet SOL.
2

Derive the View Tag

  • senderViewTag is senderAddress.confidentialViewTag(), the sender’s Solana public key in confidential rings. The indexer uses it to return matching encrypted outputs.
3

Fetch Transaction Outputs from the Indexer

  • getShieldedTransactionsByTags fetches the encrypted outputs associated with senderViewTag.
  • atSlot(depositTx.slot) waits until the indexer has the deposit at that slot.
  • The indexer returns encrypted output data. It does not decrypt the private balance.
4

Decrypt to a Private Balance

  • senderKeypair supplies the sender’s viewing key for local decryption.
  • decryptToBalances decrypts matching outputs and returns the sender’s private balances.
  • balancesAfterDeposit.balance(SOL_MINT) reads the private SOL balance.
See Concepts for how owner tagging and Private Solana Token Accounts work.

Full Code Example

Clone and run the example:
The examples use a confidential Ring on local/devnet here.

Deposit

Transfer

Withdraw

Read Private History

Didn’t find what you were looking for?

Reach out! Telegram | E-Mail | Contact