ZORP is a privacy-preserving data collection and reward distribution platform. It allows participants to submit data (e.g., EEG or survey results) pseudonymously, while enabling administrators to moderate submissions and distribute rewards in ETH or a native token.
- 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.sol
files).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].tsx
for 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.
- 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-study
provided byzorp-frontend
is recommended as this will; upload your public GPG/PGP to Irys, callZorpFactory.createStudy
with the necessary inputs, and return the address for your newZorpStudy
instance/zorp/study/start-study
provided byzorp-frontend
is recommended to use when you're ready to start your study/zorp/study/flag-invalid-submission
may 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-study
provided byzorp-frontedn
is 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 newZorpStudy
contract 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
ZorpStudy
contract instancecast send "<ZorpStudy-address>" \ --rpc-url "<rpc-url>" \ --private-key "<private-wallet-key>" \ 'startStudy()';
- End your
ZorpStudy
and 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 thatZorpFactory
is 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_key
instance 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 newZorpStudy
instance<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
ZorpStudy
instanceTBD
- Submit data to a
ZorpStudy
instance
- Recommend Web-UI end-points;
/zorp/study/submit-data
is recommended as it will download the public GPG/PGP key for a givenZorpStudy
instance, 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-status
check your on-chain status of a participant account;
0
⇔NA
no data has been submitted1
⇔SUBMITTED
data has been submitted2
⇔PAID
payment has been collected3
⇔INVALID
study moderator marked submission as invalid
/zorp/study/study-status
check on-chain status of study;
0
⇔NA
study has not been activated1
⇔ACTIVE
study is ready for data submissions2
⇔FINISHED
study is no longer accepting new data and ready to pay participants
/zorp/study/claim-reward
provided an account has the status ofSUBMITTED
and 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 ofZorpStudy
contract addresses an instance ofZorpFactory
tracks
- 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.