Documentation Index
Fetch the complete documentation index at: https://docs.inco.org/llms.txt
Use this file to discover all available pages before exploring further.
The zap.encrypt helper lets you encrypt plaintext values before sending them on-chain. incoJS currently supports three encrypted handle types:
handleTypes.euint256 — 256-bit unsigned integers.
handleTypes.ebool — booleans.
handleTypes.euint160 — Ethereum addresses (use BigInt to encode the address, effectively an eaddress).
Common setup
import { handleTypes, getViemChain, supportedChains } from '@inco/js';
import { createWalletClient, type Address } from 'viem';
import { Lightning } from '@inco/js/lite'
// Do this once at initialization
const chainId = supportedChains.baseSepolia;
const zap = Lightning.latest('testnet', chainId);
const walletClient = createWalletClient({
chain: getViemChain(chainId),
account: /* Choose your account, e.g. from window.ethereum */,
transport: /* Choose your transport, e.g. from Alchemy */,
});
const dappAddress = '0x00000000000000000000000000000000deadbeef'; // Your contract
Encrypt an euint256
const amount = 42n;
const ct = await zap.encrypt(amount, {
accountAddress: walletClient.account.address,
dappAddress,
handleType: handleTypes.euint256,
});
Encrypt an ebool
const flag = true;
const ct = await zap.encrypt(flag, {
accountAddress: walletClient.account.address,
dappAddress,
handleType: handleTypes.ebool,
});
Encrypt an eaddress (aka euint160)
Addresses must be converted to a BigInt before encryption.
const address: Address = walletClient.account.address;
const ct = await zap.encrypt(BigInt(address), {
accountAddress: walletClient.account.address,
dappAddress,
handleType: handleTypes.euint160,
});
Each example returns a ciphertext HexString you can pass to your contract or store as a handle for later confidential computation.
👉 See also: How encrypted inputs are consumed on the contract side