Reveal encrypted values locally for UI display using permits
Use decryptForView to reveal a confidential (encrypted) value locally in your app so you can display it in the UI.Unlike decryptForTx, this flow does not return an on-chain-verifiable signature, and it is not meant to be published on-chain.
Read the encrypted handle (ctHash) from your contract.
Ensure you have a permit that authorizes decryption of that value.
Call decryptForView(ctHash, utype).execute() to get the plaintext.
decryptForView always decrypts using a permit (there is no .withoutPermit() mode). If your protocol intends for the plaintext to become publicly visible on-chain, use decryptForTx instead.
Know the encrypted handle (ctHash) and the encrypted type (utype).
Have a permit available for the connected chainId + account.
Getting ctHash: In most apps, ctHash comes from reading a stored encrypted value, an event arg, or a return value from a view call.
Providing utype: utype must match the ciphertext’s underlying FHE type. The SDK uses it to convert the decrypted bigint into a convenient JS type.Supported utypes:
FheTypes.Bool → returns a boolean
FheTypes.Uint160 (address) → returns a checksummed 0x... string
If you don’t have a permit yet, create one once after connecting:
Copy
Ask AI
await client.connect(publicClient, walletClient);// Creates a permit if needed, stores it, and selects it as the active permit.await client.permits.getOrCreateSelfPermit();