This is the backend server for an email-based ENS (Ethereum Name Service) system. It handles incoming emails, generates proofs, and interacts with the Ethereum blockchain to manage ENS subdomains.
Before you begin, ensure you have the following installed:
- Rust: Version 1.88 or later. We recommend using rustup to manage your Rust installation.
- Build Tools: A C compiler and development tools are required.
- On Debian/Ubuntu:
sudo apt-get update && sudo apt-get install build-essential pkg-config libssl-dev
- On macOS:
xcode-select --install
- On Windows: You can use the "Build Tools for Visual Studio".
- On Debian/Ubuntu:
- Docker and Docker Compose (Optional): For running the complete stack, including SMTP and IMAP servers.
-
Clone the repository:
git clone https://github.com/zkemail/ens-backend.git cd ens-backend
-
Install Rust toolchain: If you don't have Rust, install it via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
The project uses the 2024 edition, so a recent compiler is needed.
The server requires a config.json
file in the root directory. A sample is provided.
-
Copy the sample configuration:
cp config.sample.json config.json
-
Edit
config.json
: Openconfig.json
and fill in the required values:prover.apiKey
: Your API key for the proving service.prover.blueprintId
: The blueprint ID for the circuit.rpc[].url
: An RPC endpoint for the desired Ethereum network (e.g., from Alchemy or Infura).rpc[].privateKey
: The private key of the account that will be used to send transactions. Warning: Do not commit this file with your private key.
To build the application, run:
cargo build --release
The compiled binary will be located at target/release/ens-backend
.
After building, you can start the server:
./target/release/ens-backend
The server will start and listen on port 4500 by default.
The easiest way to run the backend along with its dependencies (like SMTP and IMAP servers) is by using Docker Compose.
-
Ensure Docker is running.
-
Configure
config.json
as described in the "Configuration" section. -
Create a
.env
file for Docker Compose: Thedocker-compose.yaml
file uses environment variables to configure thesmtp
andimap
services. Create a.env
file in the root of the project:touch .env
Add the following variables to the
.env
file, replacing the placeholder values with your actual configuration:# SMTP Server Configuration SMTP_INTERNAL_SERVER_HOST=0.0.0.0 SMTP_INTERNAL_SERVER_PORT=3000 SMTP_PORT=3000 SMTP_DOMAIN_NAME=yourdomain.com SMTP_LOGIN_ID=test SMTP_LOGIN_PASSWORD=test SMTP_MESSAGE_ID_DOMAIN=yourdomain.com # IMAP Server Configuration IMAP_LOGIN_ID=test IMAP_LOGIN_PASSWORD=test IMAP_DOMAIN_NAME=yourdomain.com IMAP_PORT=143 IMAP_AUTH_TYPE=PLAIN
-
Start the services:
docker-compose up --build
This command will build the backend image and start the backend
, smtp
, and imap
services. The backend will be available on port 4500 of your local machine.