Next.js

This Next.js project is an example dapp for React applications. It shows how to use @fhevm/react-sdk in a React app to initialize FhevmProvider, use hooks for encryption and decryption, and interact with the FHECounter contractarrow-up-right. It works out of the box on localhost and sepolia.

This example uses wagmiarrow-up-right for wallet connections and ethersarrow-up-right for contract interactions.

🌐 Live Demo: fhevm-sdk-nextjs-example.vercel.apparrow-up-right

πŸŽ₯ 6‑minute overview

Watch the demo on Google Drivearrow-up-right

πŸš€ 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 nextjs-example

Make sure to check the MetaMask localhost setup: docs/metamask-localhost.md Use a single wallet extension for reliable detection.

Config

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

To run on Sepolia network set:

Ensure MetaMask is on Sepolia. See docs/metamask-sepolia.md.

πŸ“Œ 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