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

Getting Started ​

The Nox Solidity library lets you write smart contracts that operate on encrypted data. You import the Nox library, use encrypted types like euint256 instead of uint256, and the protocol handles encryption and off-chain computation transparently.

How It Works ​

Working with confidential data in Solidity follows three steps:

  1. Receive encrypted inputs: the user encrypts a value with the JS SDK and sends a handle + proof to your contract. You call Nox.fromExternal() to validate the proof and get a typed encrypted handle.

  2. Compute on encrypted data: use Nox.add(), Nox.sub(), Nox.eq(), Nox.select(), etc. These functions emit events that trigger off-chain TEE computation. The result is a new encrypted handle.

  3. Manage access: grant permissions with Nox.allow() so handles can be reused in future transactions, and Nox.addViewer() so users can decrypt results off-chain via the JS SDK.

INFO

Operations on encrypted handles are not executed on-chain. The contract emits events, and the off-chain Runner performs the actual computation asynchronously inside a TEE enclave. The encrypted result is stored in the Handle Gateway under the deterministic handle computed on-chain.

Prerequisites ​

  • Solidity ^0.8.0
  • Hardhat 3 or Foundry
  • Node.js 18+ with npm, yarn, pnpm, or bun

Installation ​

sh
npm install @iexec-nox/nox-protocol-contracts
sh
yarn add @iexec-nox/nox-protocol-contracts
sh
pnpm add @iexec-nox/nox-protocol-contracts
sh
bun add @iexec-nox/nox-protocol-contracts

The encrypted-types package (providing euint256, ebool, etc.) is installed automatically as a dependency.

Imports ​

solidity
import {Nox, euint256, externalEuint256} from "@iexec-nox/nox-protocol-contracts/contracts/sdk/Nox.sol";

Import the Nox library along with the encrypted types you need, all from a single path. The Nox.sol file re-exports every type from EncryptedTypes.sol, so there is no need for a separate import.

Encrypted Types ​

Encrypted types are custom defined value types backed by bytes32. Each type wraps a handle, a 32-byte identifier that references encrypted data stored off-chain in the Handle Gateway.

CategoryTypesExample
BooleaneboolEncrypted true/false
Unsigned integerseuint8, euint16, ..., euint256Encrypted balances, amounts
Signed integerseint8, eint16, ..., eint256Encrypted signed values
AddresseaddressEncrypted Ethereum address
Fixed bytesebytes1, ..., ebytes32Encrypted raw bytes

Each type has a corresponding external* variant (e.g. externalEuint256) used for handles received from users that need proof validation before use.

Next Steps ​