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, and setting it up involves installing dependencies and deploying both the RISC Zero contracts and Enclave contracts.
The setup includes the following:
- RISC Zero contracts located in the
CRISP/packages/risc0
directory. - Ciphernodes (Enclave, Registry, etc.) located in the
evm
directory of the Enclave Repo (opens in a new tab).
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)
Install Dependencies
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 simple React application used to interact with the CRISP Server. Follow these steps to set it up locally:
-
Clone the repository:
git clone https://github.com/gnosisguild/CRISP.git
-
Navigate to the
client
directory:cd CRISP/packages/client
-
Install dependencies:
yarn install
-
Start the development server:
yarn 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.
Deploying the Enclave Contracts
-
Clone the Enclave Repo (opens in a new tab):
git clone https://github.com/gnosisguild/enclave.git cd enclave
-
Install the dependencies and Compile the contracts:
yarn && yarn compile
-
Navigate to the
evm
directory:cd packages/evm
-
Deploy the Enclave contracts on the local testnet:
yarn deploy:mocks --network localhost
After deployment, take note of the addresses for the following contracts:
- Enclave
- Ciphernode Registry
- Naive Registry Filter
- Mock Input Validator
Deploying the E3 Program and Verifier RISC Zero Contract
-
Set up the environment variables by by exporting the Bonsai API Key:
Note: You will need a Bonsai API Key. You can request one here (opens in a new tab).
export BONSAI_API_KEY="your_api_key" export BONSAI_API_URL="your_api_url"
-
Navigate to the
CRISP/packages/evm_base
directory and install the dependencies:cd CRISP/packages/evm_base yarn install
-
Navigate to the
CRISP/packages/risc0
directory and build the contracts:cd CRISP/packages/risc0 forge build
-
In the
risc0/script
directory, update theconfig.toml
with the deployed contract addresses:[profile.custom] chainId = 31337 riscZeroVerifierAddress = "0x0000000000000000000000000000000000000000" enclaveAddress = "your_enclave_address" inputValidatorAddress = "your_input_validator_address"
-
Export the ETH wallet private key (Anvil’s default private key):
export ETH_WALLET_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
-
Deploy the contracts:
forge script --rpc-url http://localhost:8545 --broadcast script/Deploy.s.sol
Make sure to take note of the CRISPRisc0 Contract Address, as this will serve as the E3 Program Address.
Set Up Environment Variables
Create a .env
file in the CRISP/packages/server
directory and fill in the values you noted during the previous steps:
CRON_API_KEY=your_cron_api_key # Optional for e3_cron binary
PRIVATE_KEY=your_private_key
ENCLAVE_SERVER_URL=http://0.0.0.0:4000
HTTP_RPC_URL=http://localhost:8545
WS_RPC_URL=ws://localhost:8545
CHAIN_ID=your_chain_id
ENCLAVE_ADDRESS=your_enclave_contract_address
E3_PROGRAM_ADDRESS=your_e3_program_address # CRISPRisc0 Contract Address
CIPHERNODE_REGISTRY_ADDRESS=your_ciphernode_registry_address
NAIVE_REGISTRY_FILTER_ADDRESS=your_naive_registry_filter_address
# E3 Config
E3_WINDOW_SIZE=600
E3_THRESHOLD_MIN=1
E3_THRESHOLD_MAX=2
E3_DURATION=600
# E3 Compute Provider Config
E3_COMPUTE_PROVIDER_NAME="RISC0"
E3_COMPUTE_PROVIDER_PARALLEL=false
E3_COMPUTE_PROVIDER_BATCH_SIZE=4 # Must be a power of 2
Overview
If you followed the steps correctly, you should now have:
- A local testnet running with Anvil
- Enclave contracts deployed
- RISC Zero E3 Program and Verifier contracts deployed
- CRISP Server set up with appropriate environment variables