For the complete documentation index, see llms.txt. This page is also available as Markdown.

WrappersRegistry

Query the on-chain token wrappers registry — list pairs, look up tokens, and validate confidential tokens.

High-level read interface for the on-chain ConfidentialTokenWrappersRegistry contract. Resolves the correct registry address for the current chain automatically.

Import

import { WrappersRegistry } from "@zama-fhe/sdk";

Usage

From ZamaSDK

The SDK exposes a shared registry instance via sdk.registry. This is the recommended way to access the registry — it shares the SDK's provider, chain registry addresses, and registryTTL, and maintains a single in-memory cache.

const pairs = await sdk.registry.listPairs({ page: 1 });
const result = await sdk.registry.getConfidentialToken(erc20Address);

You can also create a separate instance via sdk.createWrappersRegistry() (inherits registryTTL from the SDK):

const registry = sdk.createWrappersRegistry();
const pairs = await registry.getTokenPairs();

Standalone

import { WrappersRegistry } from "@zama-fhe/sdk";

const registry = new WrappersRegistry({ provider });
const [isValid, cToken] = await registry.getConfidentialTokenAddress(tokenAddress);

Custom chains

Override registry addresses for Hardhat or custom deployments:

Constructor

provider

GenericProvider

Provider for read-only contract calls. Any GenericProvider implementation works (e.g. the one created by createConfig or a custom implementation).

registryAddresses

Record<number, Address> | undefined

Per-chain registry address overrides, merged on top of DefaultRegistryAddresses. Mainnet and Sepolia are configured by default — pass this only for custom or local chains.

registryTTL

number | undefined

How long cached registry results remain valid, in seconds. Default: 86400 (24 hours).

Methods

getRegistryAddress

() => Promise<Address>

Resolves the registry contract address for the current chain. Throws ConfigurationError if no address is configured.

listPairs

(options?: ListPairsOptions) => Promise<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>>

List token wrapper pairs with page-based pagination. Pass metadata: true to enrich each pair with on-chain name, symbol, decimals, and totalSupply.

ListPairsOptions

Option
Type
Default
Description

page

number

1

Page number (1-indexed)

pageSize

number

100

Items per page

metadata

boolean

false

Fetch on-chain metadata for both tokens in each pair

getConfidentialToken

(tokenAddress: Address) => Promise<{ confidentialTokenAddress: Address; isValid: boolean } | null>

Look up the confidential token for a given plain ERC-20. Returns null if no pair is registered. Negative lookups are cached for 5 minutes.

getUnderlyingToken

(confidentialTokenAddress: Address) => Promise<{ tokenAddress: Address; isValid: boolean } | null>

Reverse lookup — find the plain ERC-20 for a confidential token. Returns null if no pair is registered.

refresh

() => void

Force-invalidate the in-memory cache. The next call to any read method will fetch fresh data from the chain.

getTokenPairs

() => Promise<readonly TokenWrapperPair[]>

Fetch all token wrapper pairs from the registry.

getTokenPairsLength

() => Promise<bigint>

Get the total number of registered token wrapper pairs.

getTokenPairsSlice

(fromIndex: bigint, toIndex: bigint) => Promise<readonly TokenWrapperPair[]>

Fetch a range of pairs for pagination. fromIndex is inclusive, toIndex is exclusive.

getTokenPair

(index: bigint) => Promise<TokenWrapperPair>

Fetch a single pair by index.

getConfidentialTokenAddress

(tokenAddress: Address) => Promise<readonly [boolean, Address]>

Look up the confidential token for a given plain ERC-20. Returns [isValid, confidentialTokenAddress].

The three possible states:

  • [true, nonZeroAddress] -- registered and valid

  • [false, nonZeroAddress] -- registered but revoked (address is the former confidential token)

  • [false, zeroAddress] -- not registered

getTokenAddress

(confidentialTokenAddress: Address) => Promise<readonly [boolean, Address]>

Reverse lookup — find the plain ERC-20 for a confidential token. Returns [isValid, tokenAddress].

The three possible states mirror getConfidentialTokenAddress:

  • [true, nonZeroAddress] -- registered and valid

  • [false, nonZeroAddress] -- registered but revoked

  • [false, zeroAddress] -- not registered

isConfidentialTokenValid

(confidentialTokenAddress: Address) => Promise<boolean>

Check whether a confidential token is registered and valid.

DefaultRegistryAddresses

Record<number, Address>

Exported map of built-in registry addresses for every built-in chain with a deployed registry. Includes Mainnet (1), Polygon (137), Sepolia (11155111), Polygon Amoy (80002), Hoodi (560048), InGen Testnet (364301), and BNB Smart Chain Testnet (97). Addresses are EIP-55 checksummed.

Last updated