Skip to content

Commit d4a4e1a

Browse files
authored
feat: adding a frontend confidential transfer example (#25)
1 parent 8cef799 commit d4a4e1a

File tree

114 files changed

+31053
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+31053
-0
lines changed

confidentialTransfer/.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# don't change
2+
VITE_ACL_ADDRESS=0xFee8407e2f5e3Ee68ad77cAE98c434e637f516e5
3+
VITE_KMS_ADDRESS=0x9D6891A6240D6130c54ae243d8005063D05fE14b
4+
VITE_GATEWAY_URL=https://gateway.sepolia.zama.ai/
5+
6+
# get from https://reown.com/
7+
VITE_PROJECT_ID=""
8+
9+
# change based on what you deployed
10+
VITE_CONF_TOKEN_ADDRESS=""
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [20.x]
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: npm ci
24+
- run: npm run prettier:check
25+
- run: npm run build

confidentialTransfer/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
.env
26+
.vscode

confidentialTransfer/.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

confidentialTransfer/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Fhevm React Template
2+
3+
A modern React template for building decentralized applications (dApps) with Fully Homomorphic Encryption (FHE) capabilities using fhevmjs.
4+
5+
## Features
6+
7+
- **fhevmjs**: Fully Homomorphic Encryption for Ethereum Virtual Machine
8+
- **React**: Modern UI framework for building interactive interfaces
9+
- **Vite**: Next-generation frontend build tool
10+
- **Wagmi**: React hooks for Ethereum
11+
- **Tailwind**: Utility-first CSS framework for rapid UI development
12+
- **@reown/appkit**: Comprehensive toolkit for Web3 authentication including social logins and multi-wallet support
13+
- **@radix-ui**: Unstyled, accessible UI components for building high-quality design systems and web apps
14+
15+
## Prerequisites
16+
17+
- Node.js (v20 or higher)
18+
- npm, yarn, or pnpm package manager
19+
- MetaMask or another Ethereum wallet
20+
21+
## Getting Started
22+
23+
1. Fork the following repository:
24+
[https://github.com/zama-ai/fhevm-react-template](https://github.com/zama-ai/fhevm-react-template)
25+
26+
2. Clone your repository:
27+
28+
```bash
29+
git clone https://github.com/your-username/fhevm-react-template
30+
cd fhevm-react-template
31+
```
32+
33+
1. Install dependencies:
34+
35+
```bash
36+
npm install
37+
# or
38+
yarn install
39+
pnpm install
40+
```
41+
42+
1. Configure environment variables:
43+
44+
```bash
45+
cp .env.example .env
46+
```
47+
48+
Update `.env` with your specific configuration:
49+
50+
- `VITE_ACL_ADDRESS`: fhevm specific
51+
- `VITE_KMS_ADDRESS`: fhevm specific
52+
- `VITE_GATEWAY_URL`: fhevm specific
53+
- `VITE_PROJECT_ID`: Obtain your project ID by signing up at [reown.com](https://reown.com/). This enables social login and multi-wallet support.
54+
- `VITE_CONF_TOKEN_ADDRESS`: The address of your deployed confidential ERC20 token contract on Sepolia testnet. You'll get this after deploying the smart contract.
55+
56+
## Development
57+
58+
Start the development server:
59+
60+
```bash
61+
npm run dev
62+
# or
63+
yarn dev
64+
pnpm dev
65+
```
66+
67+
Visit [http://localhost:5173/](http://localhost:5173/) to view your application.
68+
69+
## Production Build
70+
71+
Create a production-ready build:
72+
73+
```bash
74+
npm run build
75+
# or
76+
yarn build
77+
pnpm build
78+
```
79+
80+
## Development Options
81+
82+
### Using the Mocked Coprocessor
83+
84+
For faster development without testnet tokens, you can use a mocked fhevm:
85+
86+
1. Check out the `ConfidentialERC20` example in the [`mockedFrontend` branch](https://github.com/zama-ai/fhevm-react-template/tree/mockedFrontend)
87+
2. Follow the branch-specific README for setup instructions
88+
3. Develop and test your dApp locally before deploying to Sepolia
89+
90+
### Using Sepolia Testnet
91+
92+
For testing with real network conditions, deploy your dApp to Sepolia testnet:
93+
94+
1. Ensure you have Sepolia testnet ETH
95+
2. Configure your `.env` with Sepolia network details
96+
3. Deploy and test your contracts
97+
98+
## Learn More
99+
100+
- [fhevm Documentation](https://docs.zama.ai/fhevm)
101+
- [React Documentation](https://reactjs.org/)
102+
- [Vite Documentation](https://vitejs.dev/)
103+
- [Wagmi Documentation](https://wagmi.sh/)
104+
105+
## Support
106+
107+
For questions and support:
108+
109+
- [fhevm Discord Community](https://discord.gg/zamaai)
110+
- [GitHub Issues](https://github.com/zama-ai/fhevm-react-template/issues)
111+
112+
## License
113+
114+
This project is licensed under the MIT License - see the LICENSE file for details.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "src/index.css",
9+
"baseColor": "slate",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
}
20+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import reactHooks from 'eslint-plugin-react-hooks';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import tseslint from 'typescript-eslint';
6+
7+
export default tseslint.config(
8+
{ ignores: ['dist'] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ['**/*.{ts,tsx}'],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
'react-hooks': reactHooks,
18+
'react-refresh': reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
'react-refresh/only-export-components': [
23+
'warn',
24+
{ allowConstantExport: true },
25+
],
26+
'@typescript-eslint/no-unused-vars': 'off',
27+
},
28+
},
29+
);

confidentialTransfer/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Fhevm React Template</title>
7+
<meta
8+
name="description"
9+
content="React starter template that allows you to interact with Zama's fhevm."
10+
/>
11+
<meta name="author" content="zama.ai" />
12+
<meta property="og:image" content="/og-image.png" />
13+
</head>
14+
15+
<body>
16+
<div id="root"></div>
17+
<!-- IMPORTANT: DO NOT REMOVE THIS SCRIPT TAG OR THIS VERY COMMENT! -->
18+
<script src="https://cdn.gpteng.co/gptengineer.js" type="module"></script>
19+
<script
20+
src="https://cdn.zama.ai/fhevmjs/0.6.2/fhevmjs.umd.cjs"
21+
type="text/javascript"
22+
></script>
23+
<script type="module" src="/src/main.tsx"></script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)