Getting Started with CRISP
This guide will walk you through the steps to set up and run CRISP locally. CRISP is a complete example of an E3 Program, built with a modern Hardhat-based architecture that includes smart contracts, frontend applications, and secure computation components.
The setup includes the following:
- CRISP contracts: Smart contracts located in the
contracts/
directory - Applications: Frontend, server, and computation programs in the
apps/
directory - Ciphernodes: Distributed nodes managed through the Enclave CLI
- Development environment: Hardhat + Foundry hybrid setup
Quick Start with Docker (Recommended)
The fastest way to get CRISP running is using the Docker development environment:
cd examples/CRISP
# Setup and build the development environment
pnpm dev:setup
# Start all services (Anvil, Ciphernodes, Applications)
pnpm dev:up
This will:
- Build all necessary Docker containers
- Start Anvil (local blockchain)
- Deploy all contracts
- Start the ciphernode network
- Launch all CRISP applications
Available Docker Commands:
pnpm dev:setup
- Build the development containerspnpm dev:up
- Start all servicespnpm dev:down
- Stop and clean up all servicespnpm dev:build
- Rebuild containerspnpm cli
- Invoke the Server CLI inside the Docker Container
Once everything is running, you can:
- Run
pnpm cli
to start a new E3 Round. - Open
http://localhost:3000
for the client interface - Configure MetaMask with the Anvil network (see MetaMask Setup below)
- Start voting!
Manual Setup
If you prefer to set up CRISP manually or want to understand each component:
Prerequisites
Before getting started, ensure you have the following tools installed:
- Rust (programming language and package manager)
- Foundry (Ethereum development framework)
- RISC Zero toolchain (for RISC Zero program development)
- Node.js (JavaScript runtime for client-side dependencies)
- Anvil (local Ethereum node)
- Enclave CLI (for managing ciphernodes)
Install Dependencies
Install Enclave CLI
The recommended way to install the Enclave CLI is using our installer script:
curl -fsSL https://raw.githubusercontent.com/gnosisguild/enclave/main/install | bash
This will install enclaveup
, which can then install the Enclave CLI:
enclaveup install
For more installation options and details, see the Installation Guide.
Alternative: Build from Source
If you prefer to build from source:
cargo install --locked --path ./crates/cli --bin enclave -f
Install Rust and Foundry
First, install Rust and Foundry. After installation, restart your terminal.
# Install Rust
curl https://sh.rustup.rs -sSf | sh
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
Install RISC Zero Toolchain
Next, install rzup
, which provides the cargo-risczero
toolchain.
# Install rzup
curl -L https://risczero.com/install | bash
# Install the RISC Zero toolchain
rzup
Verify the installation by running the following command:
cargo risczero --version
At this point, you should have all the necessary tools to develop and deploy applications with RISC Zero (opens in a new tab).
Setting Up the Client
The Client is a React application used to interact with the CRISP Server. Follow these steps to set it up locally:
-
Navigate to the client directory:
cd examples/CRISP/client
-
Install dependencies:
pnpm install
-
Start the development server:
pnpm dev
Setting Up the CRISP Server
The CRISP server setup involves several components. This guide will walk you through each step.
Start a Local Testnet with Anvil
-
In a terminal, start a local Ethereum testnet using Anvil:
anvil
Keep this terminal open and running. Open a new terminal for the next steps.
Deploy the Enclave Contracts
-
Clone the Enclave Repository (opens in a new tab) if you haven't already:
git clone https://github.com/gnosisguild/enclave.git cd enclave
-
Install the dependencies:
pnpm install
-
Navigate to the
packages/evm
directory:cd packages/evm
-
Deploy the Enclave contracts on the local testnet:
rm -rf deployments/localhost pnpm deploy:mocks --network localhost
After deployment, take note of the addresses for the following contracts:
- Enclave: Main protocol contract
- Ciphernode Registry: Registry for compute nodes
- Filter Registry: Registry for computation filters
- Mock Input Validator: Development input validation
Deploy the CRISP Contracts
-
Navigate to the CRISP directory:
cd examples/CRISP
-
Set up the environment variables by exporting the ETH wallet private key (Anvil's default private key):
export ETH_WALLET_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
-
Optional: Set up Bonsai for faster proving (requires API key):
Note: You can request a Bonsai API Key here (opens in a new tab).
export BONSAI_API_KEY="your_api_key" export BONSAI_API_URL="your_api_url"
-
Deploy the CRISP contracts using Foundry:
FOUNDRY_PROFILE=local forge script --rpc-url http://localhost:8545 --broadcast deploy/Deploy.s.sol
Make sure to take note of the CRISP Program Contract Address, as this will serve as the E3 Program Address.
Set Up Ciphernodes
Start the ciphernodes using the Enclave CLI:
-
Set up the aggregator wallet:
enclave wallet set --name ag --private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
-
Start the ciphernode network:
enclave nodes up -v
-
Add ciphernodes to the registry:
# Navigate back to the Enclave repository cd ../../packages/evm # Add the ciphernodes pnpm ciphernode:add --ciphernode-address "0xbDA5747bFD65F08deb54cb465eB87D40e51B197E" --network "localhost" pnpm ciphernode:add --ciphernode-address "0xdD2FD4581271e230360230F9337D5c0430Bf44C0" --network "localhost" pnpm ciphernode:add --ciphernode-address "0x2546BcD3c84621e976D8185a91A922aE77ECEc30" --network "localhost"
Configuration
The CRISP project uses an enclave.config.yaml
file that defines:
- Chains: Network configuration (Hardhat/Anvil)
- Contract addresses: Enclave, Ciphernode Registry, Filter Registry
- Nodes: Configuration for ciphernodes (cn1, cn2, cn3) and aggregator (ag)
The default configuration is already set up for local development with Anvil.
MetaMask Setup
To interact with CRISP through the web interface, configure MetaMask:
-
Add the Anvil private key to your wallet:
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
-
Add the local Anvil network:
- Network Name:
Anvil Local
- RPC URL:
http://localhost:8545
- Chain ID:
31337
- Currency Symbol:
ETH
- Network Name:
-
Connect to the application at
http://localhost:3000
Next Steps
Once you have completed the setup, you can proceed to Running an E3 Program to learn how to interact with CRISP and run voting rounds.