npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nana0x/fhevm-sdk

v1.0.1

Published

Universal FHEVM SDK - Framework agnostic core for building confidential dApps

Readme

@nana0x/fhevm-sdk

FHEVM SDK - The complete toolkit for building confidential dApps with fully homomorphic encryption on Ethereum.

Features

  • Universal SDK - Works in React, Vue, Node.js, and vanilla JavaScript
  • Wagmi-like API - Intuitive, modular interface familiar to Web3 developers
  • EIP-712 Signing - Secure user decryption with wallet signatures
  • Multi-Environment - Next.js, Vue, and Node.js examples included
  • Zero Config - Works out of the box with sensible defaults
  • CLI Tools - Command-line interface for quick development
  • TypeScript First - Full type safety and IntelliSense support
  • Cross-Framework - Data encrypted in one framework works in another
  • Interactive Wizard - Guided demo experience for all operations
  • Mock Mode - Local development without real blockchain
  • Batch Operations - Efficient batch encryption and decryption

Installation

# Install the complete FHEVM SDK
pnpm install @nana0x/fhevm-sdk

# Or install specific frameworks
pnpm install @nana0x/fhevm-sdk/react    
pnpm install @nana0x/fhevm-sdk/vue      
pnpm install @nana0x/fhevm-sdk/node     

Quick Start

import { createFHEVMClient } from '@nana0x/fhevm-sdk'

// Create client
const client = createFHEVMClient({
  rpcUrl: 'https://sepolia.infura.io/v3/YOUR_INFURA_API_KEY',
  chainId: 11155111
})

// Initialize
await client.initialize()

// Encrypt
const encrypted = await client.encrypt(42, { publicKey: '0x...' })

// Decrypt
const decrypted = await client.decrypt({
  handle: encrypted,
  contractAddress: '0x...',
  usePublicDecrypt: true
})

API Reference

createFHEVMClient(config, events?)

Creates a new FHEVM client instance.

Parameters:

  • config: FHEVMConfig - Client configuration
  • events?: FHEVMEvents - Optional event handlers

Returns: FHEVMClient

FHEVMClient

The main client class for FHEVM operations.

Methods

  • initialize(): Promise - Initialize the client
  • encrypt(value, options): Promise - Encrypt a value
  • decrypt(options): Promise - Decrypt a value
  • getState(): FHEVMState - Get current client state
  • getInstance(): FhevmInstance | null - Get the FHEVM instance
  • isReady(): boolean - Check if client is ready
  • getStatus(): FHEVMStatus - Get current status
  • getError(): Error | null - Get current error
  • refresh(): Promise - Refresh/reinitialize
  • destroy(): void - Cleanup resources

Configuration

FHEVMConfig

interface FHEVMConfig {
  rpcUrl: string;                    
  chainId: number;                   
  mockChains?: Record<number, string>; 
  storage?: FHEVMStorage;            
  signal?: AbortSignal;              
}

Storage Options

// Default (IndexedDB)
const client = createFHEVMClient(config)

// In-memory storage
import { createInMemoryStorage } from '@nana0x/fhevm-sdk'
const client = createFHEVMClient({
  ...config,
  storage: createInMemoryStorage()
})

// localStorage
import { createLocalStorage } from '@nana0x/fhevm-sdk'
const client = createFHEVMClient({
  ...config,
  storage: createLocalStorage()
})

Event Handling

const client = createFHEVMClient(config, {
  onStatusChange: (status) => {
    console.log('Status:', status)
  },
  onError: (error) => {
    console.error('Error:', error)
  },
  onReady: (instance) => {
    console.log('Ready!')
  }
})

Encryption & Decryption

Encryption

const encrypted = await client.encrypt(42, {
  publicKey: '0x...',
  contractAddress: '0x...', // Optional
  params: { /* additional params */ }
})

Decryption

// Public decryption (no signature required)
const decrypted = await client.decrypt({
  handle: encrypted,
  contractAddress: '0x...',
  usePublicDecrypt: true
})

// User decryption (requires signature)
const decrypted = await client.decrypt({
  handle: encrypted,
  contractAddress: '0x...',
  signature: '0x...'
})

Error Handling

import { 
  FHEVMError, 
  FHEVMNotInitializedError,
  FHEVMEncryptionError,
  FHEVMDecryptionError 
} from '@nana0x/fhevm-sdk'

try {
  await client.encrypt(42, { publicKey: '0x...' })
} catch (error) {
  if (error instanceof FHEVMEncryptionError) {
    console.error('Encryption failed:', error.message)
  }
}

Framework Integration

This core package is designed to work with framework-specific adapters:

  • React: @nana0x/fhevm-sdk/react - Hooks and components
  • Vue: @nana0x/fhevm-sdk/vue - Composables and utilities
  • Node.js: @nana0x/fhevm-sdk/node - Server-side utilities

Examples

See the examples directory for complete usage examples:

  • Next.js Example: packages/nextjs-example/ - React app with three demos
  • Vue Example: packages/vue-example/ - Vue app with three demos
  • Node.js Example: packages/node-example/ - Node.js demos and wizard

Contributing

This package is part of the FHEVM SDK. See the main repository for contribution guidelines.

License

BSD-3-Clause-Clear License