Skip to main content

Overview

The Token-2022 confidential transfer extension keeps token balances and transfer amounts encrypted on chain while addresses stay public. A confidential token account holds a public balance and two encrypted balances: a pending balance that receives incoming funds, and an available balance that you can spend. DynamicSvmWalletClient builds, signs, and optionally broadcasts each operation for a Dynamic wallet, and it can decrypt the encrypted balances so your application can display them. There are five operations, and each one is a single Solana transaction. Amounts are strings in the token’s base units, so '1000000' is one token when the mint has 6 decimals.

How signing works

Each call to signConfidentialTransfer runs the same sequence:
  1. The SDK reads the token account state and the latest blockhash from the RPC endpoint you provide, because the secure enclave that builds the transaction cannot reach the network.
  2. The enclave builds one unsigned transaction containing the confidential instruction and its zero-knowledge proofs, using the wallet’s confidential seed.
  3. The SDK checks the transaction before signing. It refuses to sign unless the transaction is a version 1 transaction, uses only the Token-2022, associated token account, System, ZK ElGamal Proof, and Compute Budget programs, has the wallet as its only signer and fee payer, and contains exactly one confidential instruction that matches the operation, mint, token account, destination, amount, and decimals you passed.
  4. The SDK signs the transaction with the wallet’s key share in a single signing session.
  5. If you set broadcast: true, the SDK submits the transaction and waits for the confirmed commitment level.
The result contains serializedTransactions with the signed transaction as base64, signatures with its base58 signature, and transactionIds when you broadcast.

Prerequisites

  • A Solana wallet funded with SOL for network fees.
  • A Token-2022 mint with the confidential transfer extension enabled.
  • An associated token account for that mint, owned by each wallet that takes part. Your application creates these accounts. The SDK does not.
  • @solana/web3.js installed to derive token account addresses.

Step 1: Set up the client

The examples that follow use these values. Replace them with your own.
walletMetadata is the value createWalletAccount returned when you created the wallet. Load it from the cache where you stored the wallet information. signConfidentialTransfer requires it and checks that its walletId and accountAddress match the walletId and solanaAddress in the call.
chainId defaults to Solana mainnet (solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp). The cluster in chainId must match the cluster behind rpcUrl. Devnet is solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1.
rpcUrl must use https. The SDK accepts http only for localhost, 127.0.0.1, and [::1].

Step 2: Create the confidential seed

Create the confidential seed once for each wallet, before its first confidential operation. The enclave generates the seed and stores it encrypted. The method returns the wallet’s ElGamal public key and the derivation version.

Step 3: Configure the token account

configureAccount enables confidential transfers on the wallet’s token account. Run it for every token account that will send or receive confidential funds, including the recipient’s.
Pass the password you set when you created the wallet. If you hold the wallet’s externalServerKeyShares yourself, pass them as externalServerKeyShares together with the password instead of letting the SDK recover the shares.

Step 4: Deposit, apply, transfer, and withdraw

Every operation uses the same call with a different operation. The wallet must hold a public balance of the token before it can deposit.
Each operation reads the current token account state, so wait for one operation to confirm before you start the next. With broadcast: true the call returns only after the transaction reaches the confirmed commitment level. The recipient receives a transfer as a pending balance. The recipient’s wallet must run applyPendingBalance before it can transfer or withdraw those funds.

Read decrypted balances

getConfidentialBalance decrypts both encrypted balances inside the enclave and returns them as decimal strings in base units. It reads the token account at the confirmed commitment level, so the result includes any operation you have already confirmed.
The public balance is not encrypted. Read it with connection.getTokenAccountBalance(new PublicKey(tokenAccount), 'confirmed').

Sign without broadcasting

Leave out broadcast to get the signed transaction back without submitting it. Submit it yourself, and wait for confirmation before the next operation.

Supply account state yourself

By default the SDK fetches account state and the blockhash from rpcUrl. If you already have them, pass accountState, destinationAccountState, recentBlockhash, and lastValidBlockHeight and omit rpcUrl. A call that broadcasts still needs rpcUrl. accountState has the shape { data, lamports, owner }, where data is the base64 account data and lamports and owner are strings.

Error handling

Next steps

Last modified on November 4, 2026