Labyrinth
WhitepaperResearchGet Private Access
  • 🔭Labyrinth Overview
    • Introduction
    • Why Labyrinth?
    • Who can use Labyrinth?
    • Reward and Fee in Labyrinth
    • Compliance
  • ⭐Use Labyrinth web App
    • How to use the Labyrinth app?
  • 📦Labyrinth SDK
    • ❓What is Labyrinth SDK?
    • ⚒️Quickstart
      • Setup Environment
      • Initialization
      • Private Transactions
      • Balance And Transaction History
      • Protocol Integration
    • 1️⃣Getting Started
    • 🔐Shielded Account
    • 📈Transaction
    • ▶️Initializing SDK
    • 💰Balances And History
    • 📤Sending Transaction
    • 🔌Integrating with DeFi Protocols
    • Labyrinth fee structure
  • Compliance Solution
    • Overview of Compliance
    • How Compliance Works
  • 💻CLI
    • ▶️Running SeDe CLI
  • Technical Implementation
    • Cryptographic Primitives
    • Shielded Account
    • Shielded Address
    • Account Abstraction
    • 🔵Core Architecture
      • 💵Note
      • 🌲Merkle Tree
      • 🔀JoinSplits
      • 🛡️Shielded Transaction
    • 🔄Protocol Interoperability
  • Resource and support
    • Roadmap
    • FAQs
    • Whitepaper
    • Selective De-Anonymization Compliance Paper
  • Contact and socials
    • Labyrinth Website
    • Twitter
    • Discord
    • Contact Us
Powered by GitBook
On this page
  1. Labyrinth SDK
  2. Quickstart

Initialization

PreviousSetup EnvironmentNextPrivate Transactions

Last updated 1 year ago

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 .

  • 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 https://api-sepolia-optimistic.etherscan.io/api. But, when including in CoreOptions, you must include the apikey parameter. That is, API URL that you must pass is:

    https://api-sepolia-optimistic.etherscan.io/api?apikey=<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.

📦
⚒️
viem PublicClient