decrypt ​
Requests the original plaintext value associated with an encrypted handle. The connected wallet must be authorized by the on-chain ACL to access the data — only handle owners or explicitly allowed addresses can decrypt.
Decryption is gasless: the SDK authenticates the request with an EIP-712 signature, not an on-chain transaction.
What happens under the hood ​
- The SDK generates an ephemeral RSA keypair and builds an EIP-712 message.
- Your wallet signs the message (no transaction, no gas).
- The Handle Gateway verifies the signature and checks the on-chain ACL.
- The KMS returns the encrypted data wrapped with your RSA public key.
- The SDK decrypts locally — the plaintext never travels over the network.
Usage ​
import { createViemHandleClient } from '@iexec-nox/handle';
import { createWalletClient, custom } from 'viem';
import { arbitrumSepolia } from 'viem/chains';
const walletClient = createWalletClient({
chain: arbitrumSepolia,
transport: custom(window.ethereum),
});
const handleClient = await createViemHandleClient(walletClient);
const { value, solidityType } = await handleClient.decrypt(handle);Parameters ​
handle Required * ​
Type: Handle<T> (a 0x-prefixed hex string, 32 bytes)
The handle to decrypt. It must have been created on the same chain as the one the client is connected to.
const { value, solidityType } = await handleClient.decrypt(handle); Gasless operation
Decryption uses an EIP-712 signature for authentication — it does not submit an on-chain transaction and costs no gas.
Access control
The connected wallet must be authorized to decrypt the handle. Authorization is managed through the on-chain ACL: only the handle owner or addresses explicitly granted access can request decryption.
Publicly decryptable handles
For handles that have been marked as publicly decryptable, use publicDecrypt instead. It does not require ACL authorization or an EIP-712 signature.
Return Value ​
{
value: boolean | string | bigint;
solidityType: SolidityType;
}value ​
Type: boolean | string | bigint
The decrypted plaintext. The JavaScript type depends on the Solidity type encoded in the handle:
| Solidity type | JavaScript type | Example |
|---|---|---|
bool | boolean | true |
string | string | "Hello, Nox!" |
address, bytes, bytesN | string | "0x742d…bEb0" |
uintN, intN | bigint | 1000n |
solidityType ​
Type: SolidityType
The Solidity type decoded from the handle (e.g. "uint256", "bool", "address"). Useful when you receive a handle without knowing its type ahead of time.
const { value, solidityType } = await handleClient.decrypt(handle);
console.log(`${solidityType}:`, value);
// e.g. "uint256: 1000n" or "bool: true"