🚧 This documentation is currently under development. Content may be incomplete or subject to change. 🚧
Skip to content

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 ​

  1. The SDK generates an ephemeral RSA keypair and builds an EIP-712 message.
  2. Your wallet signs the message (no transaction, no gas).
  3. The Handle Gateway verifies the signature and checks the on-chain ACL.
  4. The KMS returns the encrypted data wrapped with your RSA public key.
  5. The SDK decrypts locally — the plaintext never travels over the network.

Usage ​

ts
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.

ts
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 ​

ts
{
  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 typeJavaScript typeExample
boolbooleantrue
stringstring"Hello, Nox!"
address, bytes, bytesNstring"0x742d…bEb0"
uintN, intNbigint1000n

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.

ts
const { 
value
,
solidityType
} = await
handleClient
.
decrypt
(
handle
);
console
.
log
(`${
solidityType
}:`,
value
);
// e.g. "uint256: 1000n" or "bool: true"