Now that you have your environment set up already, let's see about how to instantiate.

You can instantiate the SDK by passing it the CoreOptions object as an argument. Although, CoreOptions has many fields most are optional. We'll focus on the required options for now.

import { PublicClient } from 'viem';
import { ShieldedAccount } from '@zkfi-tech/account';

// Only showing required fields, skipping any optional fields for now
type CoreOptions = {
  chainId: number;
  account: ShieldedAccount;
  rpc: PublicClient | string;
  explorerApi: string;
  • chainId

    The target chain on which you want to utilize the deployed instance of zkFi.

  • account It is the shielded account of the user who wants to perform private transactions of enquire about its balance or transaction history. A ShieldedAccount can be simply generated from a random seed. A seed is a random bigint number generated from a secure entropy source. You can generate the account by: const account = ShieldedAccount.generate(seed) Now you can pass the account to the CoreOption.

  • rpc RPC URL of the provided chain or the viem PublicClient .

  • explorerApi API URL of block explorer. You must append the API key of the block explorer in the API URL itself. For example, Optimism Sepolia's base API URL is But, when including in CoreOptions, you must include the apikey parameter. That is, API URL that you must pass is:<YOUR_API_KEY>

After configuring options simply create an SDK instance as:

import {Core, CoreOptions} from '@zkfi-tech/core';

const opts: CoreOptions = {
// set options here

const zkfi = new Core(opts);

The SDK instance (zkfi) above is ready to be utilized now. Next, let's see how to craft a shielded/private transaction i.e a ZTransaction instance.

Last updated