ZORP Protocol is a permissionless and open research data and reward distribution platform. ZORP enables a distributed set of participants to submit data (particularly EEG signatures or survey results) to managers, who moderate submissions and distribute token rewards. ZORP Protocol enables coordinated research efforts to be executed at massive scale: real human participants can now interface directly with experiment coordinators without needing approval from third-party intermediaries such as Institutional Review Boards or the various Subcommittees that often prolong the R&D process.
- Smart Contracts (
zorp-contracts): Written in Solidity using Foundry, handle study creation, data submission, moderation, and reward payout. - Front-End (
zorp-frontend): A Next.js + RainbowKit application that lets users create and manage studies, upload data to IPFS, and interact with the contracts on-chain (e.g., Base Goerli / Base mainnet).
zorp/
├─ README.md
├─ zorp-contracts/
│ ├─ foundry.toml
│ ├─ src/
│ ├─ script/
│ ├─ test/
│ ├─ lib/
│ └─ ...
├─ zorp-frontend/
│ ├─ package.json
│ ├─ app/
│ ├─ components/
│ ├─ ...
└─ .gitignore- Purpose: Contains all the ZORP smart contracts (e.g.,
ZorpFactory.sol,ZorpStudy.sol) and Foundry configuration/testing. - Key Files:
foundry.toml: Foundry configuration (compiler settings, etc.).src/: Your main Solidity source files (contracts).test/: Solidity tests using Foundry's test framework.script/: Scripts for deploying or interacting with the contracts (.s.solfiles).lib/: For external libraries like OpenZeppelin.
- Install Foundry (if not already):
curl -L https://foundry.paradigm.xyz | bash foundryup⚠️ Be sure to double-check official installation documentation - Build the project:
cd zorp-contracts forge build - Run tests:
forge test - Deploying:
- Syntax:
forge script script/DeployZorp.s.sol --rpc-url <YOUR_RPC> --private-key <YOUR_KEY> --broadcast - Example for Anvil:
_test_net_url='127.0.0.1:8545'; _test_private_key0='0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; pushd "zorp-contracts"; forge script \ --offline \ --broadcast \ --rpc-url "${_test_net_url}" \ --private-key "${_test_private_key0}" \ script/DeployAnvilZorp.s.sol:DeployAnvil;
- Syntax:
- Purpose: A React-based web application for managing studies, uploading data to IPFS, and interacting with the ZORP contracts.
- Key Files:
package.json: Manages dependencies, including Next.js, wagmi, RainbowKit.pages/: Next.js pages likeindex.tsx,[studyId].tsxfor study detail, etc.components/: Reusable UI components.styles/: Tailwind CSS files or global styles.
- Install Dependencies:
cd zorp-frontend npm install # or yarn install
- Configure Environment (e.g.,
.env.local):- You may need variables for NEXT_PUBLIC_RPC_URL, NEXT_PUBLIC_CONTRACT_ADDRESS, or IPFS_API_KEY if using a pinned storage service.
- Start the Dev Server:
npm run dev # or yarn dev - Open http://localhost:3000 in your browser to see the app.
ZORP provides a full-featured VS Code Dev Container setup for seamless onboarding and reproducible development. This is the easiest way to get started, as it automatically installs all dependencies for both the smart contracts and frontend.
- Docker installed and running
- Visual Studio Code with the Dev Containers extension
- Open the project in VS Code
- Use
File > Open Folder...and select the rootzorp/directory.
- Use
- Reopen in Container
- When prompted, or via the Command Palette (
Ctrl+Shift+P→ "Dev Containers: Reopen in Container"), VS Code will build and start the dev container using.devcontainer/devcontainer.jsonanddocker-compose.yml.
- When prompted, or via the Command Palette (
- Automatic Setup
- On first launch, the container will run
.devcontainer/setup.shto:- Install system dependencies (curl, libusb)
- Install Foundry and add it to the PATH
- Install contract dependencies and build contracts
- Install frontend dependencies
- All ports (3000 for frontend, 8545 for local blockchain) are forwarded automatically.
- On first launch, the container will run
- Start Services
- The dev container setup provides three main services:
dev-base: Main development shell (where VS Code attaches)anvil: Local blockchain node (auto-starts)frontend: Next.js dev server (auto-starts)
- If not started automatically, you can run the following in the VS Code terminal:
- To start the local blockchain (Anvil):
docker-compose -f .devcontainer/docker-compose.yml up anvil
- To start the frontend dev server:
docker-compose -f .devcontainer/docker-compose.yml up frontend
- To start the local blockchain (Anvil):
- The dev container setup provides three main services:
- Access the App
- Open http://localhost:3000 for the frontend.
- The local blockchain is available at
http://localhost:8545.
- Prerequisites:
- Create a GPG/PGP key pair for encryption
- Fund your Base wallet and Irys account
- Create a study:
- Recommend Web-UI end-points;
/zorp/factory/create-studyprovided byzorp-frontendis recommended as this will; upload your public GPG/PGP to Irys, callZorpFactory.createStudywith the necessary inputs, and return the address for your newZorpStudyinstance/zorp/study/start-studyprovided byzorp-frontendis recommended to use when you're ready to start your study/zorp/study/flag-invalid-submissionmay be used to flag individual account submissions as invalid, this will delete CID pointer from the contract storage and mark the account as unable to receive a payout after the study is ended/zorp/study/end-studyprovided byzorp-frontednis recommended to use when you're ready to end your study and allow participants to withdraw their payout
- CLI is more involved, and has more opportunity for mistakes;
- Generate an IPFS CID from your public GPG/PGP key
- Start a Node REPL
pushd zorp-frontend node --experimental-transform-types - Generate an IPFS CID from public GPG/PGP key
var { cidFromFile } = await import('./src/lib/utils/ipfs.ts'); var fs = await import('fs'); var file = fs.readFileSync('<path-to-public-gpg-key>'); if (!('arrayBuffer' in file)) { file.arrayBuffer = async () => new ArrayBuffer(file); } console.log(await cidFromFile(file));
- Restore previous current working directory
popd zorp-frontend
- Upload your public GPG/PGP key to Irys
irys upload "<pubic-gpg-key>" \ -t base \ -w "<private-wallet-key>" \ --tags 'IPFS-CID' "<cid-from-previous-step>" \ 'Content-Type' 'application/pgp-encrypted';
- Fund and create a new study, search output for
"Deployed to:"address for your newZorpStudycontract instancecast send "<ZorpFactory-address>" \ --rpc-url "<url>" \ --private-key "<private-wallet-key>" \ --value "<amount-to-fund-study-with>" \ 'createStudy(address,string)(address)' \ "<public-wallet-key>" \ "<cid-from-previous-step>";
- Start your new
ZorpStudycontract instancecast send "<ZorpStudy-address>" \ --rpc-url "<rpc-url>" \ --private-key "<private-wallet-key>" \ 'startStudy()';
- End your
ZorpStudyand allow participants to claim payoutcast send "<ZorpStudy-address>" \ --rpc-url "<url>" \ --private-key "<private-wallet-key>" \ 'endStudy()';
Notes
In above CLI examples there are many "fill in your own values" (
<word>) opportunities for mistakes, the following will attempt to help explain, but if unsure please either use the Web-UI or search GitHub Issues or ask on Discord;
<pubic-gpg-key>should be the file-path to the public GPG/PGP key study participants will use to encrypt data prior to uploading to Irys, and submitting the CID to your instance ofZorpStudy.submitData(string)<rpc-url>should be the RPC URL of the chain thatZorpFactoryis deployed on that you wish to use, for local testing this may be127.0.0.1:8545<cid-from-previous-step>should be whatconsole.log(await cidFromFile(file))output, and eventually will be saved to yourZorpStudy.encryption_keyinstance for participants to use when submitting encrypted data<private-wallet-key>should be the crypto-coin wallet's private key used for publishing GPG/PGP public key and creating a newZorpStudyinstance<ZorpFactory-address>should be the smart contract address for theZorpFactory(notZorpStudy) accessible via same network/chain that<rpc-url>can reach<amount-to-fund-study-with>is the total amount that will be split evenly among all participants afterZorpStudy.endStudy()is executed, please be sure to estimate a fair value to encourage continued involvement from high-quality data submitters!<ZorpStudy-address>is returned byZorpFactory.createStudy(...)and is the address you must use for administrating your study
- Prerequisites:
- Create a GPG/PGP key pair for encryption
- Fund your Base wallet and Irys account
- Discover a
ZorpStudyinstanceTBD
- Submit data to a
ZorpStudyinstance
- Recommend Web-UI end-points;
/zorp/study/submit-datais recommended as it will download the public GPG/PGP key for a givenZorpStudyinstance, request your public GPG/PGP key, locally encrypt your data submission with both GPG/PGP public keys as recipients, upload encrypted data to Irys, and then callZorpStudy.submitData(string)with necessary information/zorp/study/participant-statuscheck your on-chain status of a participant account;
0⇔NAno data has been submitted1⇔SUBMITTEDdata has been submitted2⇔PAIDpayment has been collected3⇔INVALIDstudy moderator marked submission as invalid
/zorp/study/study-statuscheck on-chain status of study;
0⇔NAstudy has not been activated1⇔ACTIVEstudy is ready for data submissions2⇔FINISHEDstudy is no longer accepting new data and ready to pay participants
/zorp/study/claim-rewardprovided an account has the status ofSUBMITTEDand the study has the status ofFINISHED, this end-point maybe used to request payment for data submitted
The zorp-contracts/src/IZorpStudy.sol file contains interface contract code that, for study creators, maybe be useful for data collection and moderation as well as, for participants, discovery of new studies. Check the doc-comments for example usage for both React-ish web-apps and CLI scripting.
IZorpStudy_Functions.paginateSubmittedData→ Return a possibly sparse array of CID strings pointing to submitted data
IZorpStudy_Functions.paginateSubmittedData→ Intended for off-chain requests for bulk lookup ofZorpStudycontract addresses an instance ofZorpFactorytracks
- Fork the repo or clone it locally.
- Work on a feature branch (e.g.,
feature/add-contract-tests). - Submit a Pull Request for review.
This project is licensed under GPL-3.0.