- Read fetches encrypted Private Solana Token Accounts from the indexer with dedicated RPC methods.
- Only the user, or anyone the user authorizes, can decrypt balances with their viewing key.
- Use it after a private balance changes and before a transfer.
Compare to getBalance / getAccount
Compare to getBalance / getAccount
getBalancereturns public SOL.getAccountreturns a public token account.- The RPC returns the public balance.
Get Started
- TypeScript Client
- Rust Client
1
Prerequisites
The TypeScript examples require Node.js 24 or later, pnpm 11.18.0, and the Solana CLI.
Connect to Endpoints
Connect to Endpoints
- Devnet
- Localnet
.env
2
Derive the View Tag
senderViewTagissenderAddress.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
getShieldedTransactionsByTagsfetches the encrypted outputs associated withsenderViewTag.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
senderKeypairsupplies the sender’s viewing key for local decryption.decryptToBalancesdecrypts 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.