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

GenericProvider

Interface that all provider adapters must implement for read-only chain access.

Interface that all provider adapters must implement for read-only chain access. You only need this if you are building a custom provider -- otherwise use ViemProvider, EthersProvider, or the wagmi createConfig which builds one internally.

Import

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

Definition

interface GenericProvider {
  getChainId(): Promise<number>;
  readContract(config: ReadContractConfig): Promise<unknown>;
  waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt>;
  getBlockTimestamp(): Promise<bigint>;
}

Usage with createConfig

Pass a custom provider to the generic createConfig from @zama-fhe/sdk:

import { createConfig, ZamaSDK, memoryStorage } from "@zama-fhe/sdk";
import { node } from "@zama-fhe/sdk/node";
import { sepolia } from "@zama-fhe/sdk/chains";

const config = createConfig({
  chains: [sepolia],
  provider: myCustomProvider,
  storage: memoryStorage,
  relayers: { [sepolia.id]: node() },
});
const sdk = new ZamaSDK(config);

Implementing a custom provider

Methods

getChainId

Return the chain ID this provider is connected to.

readContract

Execute a read-only contract call. ReadContractConfig contains address, abi, functionName, and args.

waitForTransactionReceipt

Poll for a transaction receipt by hash.

getBlockTimestamp

Return the timestamp of the latest block.

Last updated