Node.js CLI

This Node.js project is a CLI example. It shows how to use @fhevm/sdk/node to initialize a Node client, encrypt inputs, send transactions, and decrypt values with the FHECounter contractarrow-up-right. It works on localhost and sepolia.

This example uses ethers for provider, wallet, and contract interactions.

πŸš€ Running the example

Localhost works out of the box If you want to run it on localhost, just do (from root):

# Run local hardhat node with all contracts
pnpm chain
# Run example
pnpm nodejs-example

Config

Create .env in this folder based on env.examplearrow-up-right.

To run on Sepolia network set in .env:

NETWORK_MODE=sepolia
PRIVATE_KEY=your_private_key_here

πŸ“Œ Note By default this example uses a pre-deployed FHECounter contractarrow-up-right at 0x6134E9810A204661eaB5a189A44BB7F1CB2a4196 with RPC https://ethereum-sepolia-rpc.publicnode.com.

To replace any contract address or RPC, see all variables in env.examplearrow-up-right.

πŸ“ Folder structure

Last updated