Encryption
The encryption module provides client-side data encryption using Inco JS SDK for Inco-compatible values.Import
Basic Usage
Example: Encrypt for Confidential Token Transfer
Real-World Example: Encrypt Multiple Values
API Reference
encryptValue(value)
Encrypts a single value for use with Inco’s TEE infrastructure.
Parameters:
value:EncryptableValue- The value to encrypt
Promise<string> - Hex-encoded encrypted data
Types
EncryptableValue
Error Handling
Encryption Errors
Thrown byencryptValue() as EncryptionError.
| Error Message | Cause | Solution |
|---|---|---|
Cannot encrypt null or undefined value | Passed null or undefined to encryptValue() | Ensure the value is defined before encrypting |
Floating-point numbers are not supported. Use integers or BigInt instead | Passed a decimal number like 10.5 | Use integers (10) or BigInt (10n) instead |
Unsupported value type. Only bigint, number (integers), and boolean are supported | Passed a string, object, or other unsupported type | Convert to BigInt for amounts, use boolean for flags |
Encryption failed: <details> | Internal encryption error | Check the error details; may indicate SDK misconfiguration |