Delegated decryption
Grant another address the right to decrypt confidential balances, then read those balances as a delegate.
Example
import { createConfig, ZamaSDK } from "@zama-fhe/sdk";
import { sepolia } from "@zama-fhe/sdk/chains";
const sdk = new ZamaSDK(config); // config from createConfig()
const token = sdk.createToken("0xConfidentialToken");
// 1. Delegator grants decryption rights
const { txHash } = await sdk.delegations.delegateDecryption({
contractAddress: token.address,
delegateAddress: "0xDelegate",
});
// 2. Delegate reads the delegator's balance — no wait needed. Propagation
// usually completes within ~10 blocks (a few seconds), and the SDK retries
// across that window internally.
const balance = await token.decryptBalanceAs({ delegatorAddress: "0xDelegator" });Steps
1. Grant delegation
2. ACL propagation (handled for you)
3. Decrypt as delegate
4. Batch decryption across tokens (optional)
5. Revoke delegation (optional)
6. Handle errors (optional)
Next steps
Last updated