Skip to content

Commit 896a3cb

Browse files
Merge pull request #36 from airchains-network/development
Development
2 parents 8eb5b1c + 592e7aa commit 896a3cb

File tree

17 files changed

+4374
-886
lines changed

17 files changed

+4374
-886
lines changed

docs/api-reference/index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
id: api-reference
3+
title: API Reference
4+
description: --
5+
slug: /api-reference
6+
hide_table_of_contents: true
7+
sidebar_position: 1
8+
---
9+
10+
# API Reference
11+
12+
import UnderProgress from '@site/src/components/Docs/under-progress.js';
13+
14+
<UnderProgress />

docs/develop/contribute.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
id: contribute
3+
title: Contribute
4+
description: Learn how to contribute to various Airchains ecosystem repositories with guidelines and best practices.
5+
slug: /develop/contribute
6+
hide_table_of_contents: true
7+
sidebar_position: 5
8+
---
9+
10+
# Contribute
11+
12+
import UnderProgress from '@site/src/components/Docs/under-progress.js';
13+
14+
<UnderProgress />
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
id: compiling-and-deploying
3+
title: Compiling and Deploying
4+
description: compile and deploy FHE-enabled Solidity contracts
5+
slug: /develop/exercise/hands-on-fhevm/compiling-and-deploying
6+
hide_table_of_contents: false
7+
sidebar_position: 4
8+
---
9+
10+
# Compiling and Deploying fhEVM Smart Contracts
11+
12+
This guide provides instructions on compiling and deploying Fully Homomorphic Encryption Virtual Machine (fhEVM) smart contracts. These contracts operate in an environment where data remains encrypted, offering enhanced privacy.
13+
14+
If you are new to blockchain development, **learn the basics of compiling, deploying, and interacting with standard Ethereum smart contracts first**. There are many tutorials online that explain these foundational concepts, which will make it easier to understand fhEVM development.
15+
16+
The template repository contains pre-written codes for compilation and deployment, along with sample contracts. Follow the steps below to get started.
17+
18+
---
19+
20+
## fhEVM Smart Contracts
21+
22+
The compilation code uses the Solidity compiler (`solc`) to compile smart contracts and extract their ABI and bytecode. It also handles special import resolutions required for fhEVM contracts.
23+
24+
### Steps to Compile and Deploy
25+
26+
1. Ensure your contract file is placed in the `contracts/` directory.
27+
2. Navigate to `contract-deploy.js` and search for the `contractName` variable, then replace its value with the name of your desired contract.
28+
29+
### Output
30+
31+
The compiled ABI is stored in the `build/` directory. For example:
32+
33+
- ABI: `build/<ContractName>.json`
34+
- Bytecode: Generated and used internally by the deployment script.
35+
36+
**Note**: The script automatically resolves imports from `node_modules/`.
37+
38+
### Deployment of fhEVM Smart Contracts
39+
40+
The deployment process requires:
41+
42+
- A JSON-RPC endpoint of the fhEVM-compatible network.
43+
- A private key for deploying the contract.
44+
- The compiled contract file (from the `build/` directory).
45+
- Constructor arguments (if any).
46+
47+
The `contract-deploy.js` script includes a function call that deploys your contract using a **_test private key_** derived from the mnemonic provided in the `.env` file.
48+
49+
---
50+
51+
## What's Next?
52+
53+
Let's continue to writing fhEVM smart contracts. Move on to the **[Writing Smart Contracts](./writing-smart-contract.md)** section to learn more.
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
id: hands-on-fhevm
3+
title: Hands-on FHEVM
4+
description: --
5+
slug: /develop/exercise/hands-on-fhevm/hands-on-fhevm
6+
hide_table_of_contents: false
7+
sidebar_position: 1
8+
---
9+
10+
# Hands-on FHEVM
11+
12+
**fhEVM** enables **privacy-preserving smart contracts** on **EVM-compatible blockchains**. This hands-on guide will walk you through **understanding, setting up, and working with fhEVM** to develop encrypted smart contracts.
13+
14+
### What You’ll Learn
15+
16+
- Basics of **fhEVM and its architecture**.
17+
- Setting up a **local fhEVM development environment**.
18+
- Writing, compiling, and deploying **FHE-enabled Solidity contracts**.
19+
- Testing encrypted contract interactions.
20+
21+
---
22+
23+
## **1. Understanding fhEVM**
24+
25+
fhEVM is a **privacy-first smart contract platform** that allows computations on encrypted data **without decryption**. This ensures **on-chain privacy** while maintaining **verifiability and interoperability**.
26+
27+
### **Core Principles**
28+
29+
1. **Security**: No compromise on blockchain security.
30+
2. **Public Verifiability**: Confidential yet verifiable computations.
31+
3. **Developer-Friendly**: Familiar Solidity tools.
32+
4. **Composability**: Interoperable confidential and public contracts.
33+
34+
### **Key Features**
35+
36+
- **Encrypted Data Types**: `ebool`, `euintX`, `eaddress`, `ebytesX`, etc.
37+
- **Homomorphic Computation**: Arithmetic on encrypted numbers.
38+
- **Confidential Transactions**: Data remains encrypted even on-chain.
39+
- **EVM-Compatible**: Supports Solidity with added FHE functionalities.
40+
41+
### **Encrypted Data Types**
42+
43+
fhEVM introduces special encrypted types for secure computations:
44+
45+
- **Booleans**: `ebool`
46+
- **Integers**: `euint4`, `euint8`, ... `euint256`
47+
- **Addresses**: `eaddress`
48+
- **Bytes**: `ebytes64`, `ebytes128`, `ebytes256`
49+
- **Inputs**: `einput`
50+
51+
### **Type Casting**
52+
53+
fhEVM provides utility functions to convert between encrypted types:
54+
55+
- `TFHE.asEbool(value)`: Converts a boolean to an encrypted boolean.
56+
- `TFHE.asEuintX(value)`: Converts an integer to an encrypted integer.
57+
- `TFHE.asEaddress(value)`: Converts an address to an encrypted address.
58+
59+
fhEVM empowers secure and efficient computation on encrypted data while preserving blockchain functionality.
60+
61+
---
62+
63+
## 2. **fhEVM Architecture**
64+
65+
### **Core Components**
66+
67+
fhEVM consists of several **interdependent components**:
68+
69+
- **Smart Contracts**: Interact with encrypted data to execute logic securely on the blockchain.
70+
- **fhEVM-native**: On-chain processing that handles homomorphic computations on ciphertexts using evaluation keys.
71+
- **Key Management System (KMS)**: Safeguards private keys for decryption and re-encryption processes.
72+
- **Gateway**: Acts as a bridge between the blockchain and the KMS, enabling secure operations like decryption and re-encryption.
73+
- **Connector**: A service that connects the gateway to the KMS.
74+
- **Gateway Store**: A service that stores ciphertexts.
75+
- **fhEVM.js Library**: Facilitates client-side interactions such as encryption, decryption, and re-encryption.
76+
77+
---
78+
79+
### **End-to-End Confidentiality**
80+
81+
fhEVM ensures that:
82+
83+
- **Plaintext data is never exposed** during processing or transmission.
84+
- **Homomorphic computations** enable complex operations on encrypted data.
85+
- **Secure re-encryption** allows sharing and interoperability without compromising privacy.
86+
87+
This **tightly integrated architecture** supports **decentralized applications (dApps)** requiring privacy-preserving operations, paving the way for **more secure and trustless systems**.
88+
89+
For more detailed insights, you can refer to the **[official documentation by Zama](https://docs.zama.ai/fhevm)**.
90+
91+
---
92+
93+
### **What's Next?**
94+
95+
Now that you understand the **fhEVM architecture**, let's set up an **fhEVM network**.
96+
➡ Move on to **[Network Setup](./setting-up-network.md)** to learn how to proceed.
97+
98+
99+
<!--
100+
## **3. Setting Up Your Development Environment**
101+
102+
Before writing encrypted contracts, install the necessary tools.
103+
104+
### **Prerequisites**
105+
106+
✔ **Go** (`v1.23.x` or later)
107+
✔ **Docker** (`v26.x.x` or later)
108+
✔ **Node.js** (`v20.x` or later)
109+
110+
📖 **[Full Setup Guide](./preparation.md)**
111+
112+
---
113+
114+
## **4. Deploying fhEVM Network**
115+
116+
We will **set up a local fhEVM test network** using Docker.
117+
118+
### **Start the Network**
119+
120+
```bash
121+
make run-full
122+
```
123+
124+
### **Fund Accounts**
125+
126+
```bash
127+
npm run fund
128+
```
129+
130+
### **Deploy Core Contracts**
131+
132+
```bash
133+
npm run core
134+
```
135+
136+
📖 **[Full Network Setup Guide](./setting-up-network.md)**
137+
138+
---
139+
140+
## **5. Writing and Deploying Encrypted Smart Contracts**
141+
142+
fhEVM supports **Fully Homomorphic Encryption (FHE)** within Solidity contracts.
143+
144+
### **Key Contract Operations**
145+
146+
✔ **EncryptedERC20**: Secure token minting, transfer, and approvals.
147+
✔ **Homomorphic Computation**: Arithmetic on encrypted balances.
148+
✔ **Decryption via Gateway**: Interact with KMS securely.
149+
150+
📖 **[Writing Smart Contracts](./writing-smart-contract.md)**
151+
📖 **[Deploying Smart Contracts](./compiling-and-deploying.md)**
152+
153+
---
154+
155+
## **6. Testing Encrypted Contracts**
156+
157+
To validate your contracts, write **JavaScript-based tests** using `ethers.js`.
158+
159+
### **Example Test Cases**
160+
161+
✔ **Minting Tokens**
162+
✔ **Encrypted Transfers**
163+
✔ **Encrypted Approvals**
164+
✔ **Balance Decryption**
165+
166+
📖 **[Writing Test Files](./writing-contract-test-files.md)**
167+
168+
---
169+
170+
## **7. Conclusion**
171+
172+
By completing this hands-on guide, you now understand:
173+
174+
- **How fhEVM works** and how it enables privacy in smart contracts.
175+
- **How to set up and deploy an encrypted EVM-compatible network**.
176+
- **How to write and test FHE-enabled Solidity contracts**.
177+
178+
### **Next Steps**
179+
180+
🔹 Explore **advanced encrypted contract interactions**.
181+
🔹 Contribute to **fhEVM projects and research**.
182+
🔹 Learn more from **[Zama’s Official Documentation](https://docs.zama.ai/fhevm)**.
183+
184+
📖 **[Final Thoughts & Summary](./08-conclusion.md)**
185+
186+
---
187+
188+
## **🚀 Ready to Build?**
189+
190+
You’re now equipped with the **fundamentals of fhEVM**. Start experimenting with your own encrypted smart contracts and push the boundaries of **on-chain privacy**! -->
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
id: prerequisites
3+
title: Prerequisites
4+
description: This guide walks you through configuring your development setup, ensuring seamless interaction with the FHEVM network for encrypted smart contract execution
5+
slug: /develop/exercise/hands-on-fhevm/prerequisites
6+
hide_table_of_contents: false
7+
sidebar_position: 2
8+
---
9+
10+
# Prerequisites
11+
12+
Here are the prerequisites to set up your development environment for working with **fhEVM**.
13+
14+
Before proceeding, ensure your system meets the following requirements:
15+
16+
- **Operating System**: Linux, macOS, or Windows with WSL2
17+
- **Go**: Version `v1.23.x` or higher
18+
- **Docker**: Version `v26.x.x` or higher
19+
- **Node.js**: Node.js `v20.x` or higher
20+
21+
---
22+
23+
## Step 1: Install Go
24+
25+
1. Visit the [Go Downloads Page](https://go.dev/dl/) and download the installer for your operating system.
26+
2. Follow the installation instructions specific for your OS.
27+
3. Verify the installation by running the following command:
28+
29+
```bash
30+
go version
31+
```
32+
33+
You should see the installed Go version in the output.
34+
35+
---
36+
37+
## Step 2: Install Docker
38+
39+
1. Follow the official Docker installation guide for your operating system:
40+
- [Install Docker on Linux](https://docs.docker.com/engine/install/)
41+
- [Install Docker on macOS](https://docs.docker.com/docker-for-mac/install/)
42+
2. After installation, verify Docker is installed correctly:
43+
44+
```bash
45+
docker --version
46+
```
47+
48+
You should see the installed Docker version in the output.
49+
50+
3. Ensure Docker can run without `sudo` (Linux users only):
51+
52+
```bash
53+
sudo groupadd docker
54+
sudo usermod -aG docker $USER
55+
newgrp docker
56+
```
57+
58+
Verify it works:
59+
60+
```bash
61+
docker run hello-world
62+
```
63+
64+
---
65+
66+
## Step 3: Install Docker Compose Plugin
67+
68+
1. Follow the official Docker Compose plugin installation guide for your operating system:
69+
- [Install Docker Compose Plugin on Linux](https://docs.docker.com/compose/install/linux/)
70+
- [Install Docker Compose Plugin on macOS](https://docs.docker.com/compose/install/mac/)
71+
2. After installation, verify Docker Compose plugin is installed correctly:
72+
73+
```bash
74+
docker compose version
75+
```
76+
77+
You should see the installed Docker Compose plugin version in the output.
78+
79+
---
80+
81+
## Step 4: Install Node.js
82+
83+
1. Install Node.js and npm using the official guide for your operating system: [Node.js Downloads](https://nodejs.org/en/download/)
84+
85+
- Select the **LTS** version for better stability.
86+
87+
2. Verify the installation by running the following commands:
88+
89+
```bash
90+
node -v
91+
npm -v
92+
```
93+
94+
These should output the installed Node.js and npm versions.

0 commit comments

Comments
 (0)