Raktbeej is a decentralized science platform where researchers can upload papers, define royalty splits with collaborators, and receive donations that are distributed automatically on-chain.
The idea is simple: if research is collaborative, payouts should be collaborative too, and everyone should be able to verify how money is split.
- What is Raktbeej?
- What Problem It Solves
- How It Works
- Tech Stack
- Project Structure
- Prerequisites
- Setup Guide
- Environment Variables
- Database Setup
- Smart Contract Deployment
- Running the App
- Feature Walkthrough
- Contributing
Raktbeej is a DeSci project built for fair research royalties.
When a paper is uploaded, the authors can define wallet addresses and percentage splits. Later, when someone donates, the smart contract routes funds to each collaborator according to those predefined splits.
Most publishing and funding systems are not transparent about how revenue is shared.
Raktbeej addresses three common issues:
- Open-access work usually has no direct payout system.
- Royalty distribution between collaborators is often manual and unclear.
- Donors cannot easily verify whether contributors were paid fairly.
Author uploads paper
-> PDF stored on IPFS via Pinata
-> Paper metadata and royalty splits saved in Neon Postgres
-> Donor sends funds to Polygon Amoy contract
-> Contract distributes funds to author wallets based on saved splits
Why this approach works:
- Metadata stays off-chain, so authors avoid unnecessary gas costs.
- Files are not tied to a single centralized server.
- Donation distribution is verifiable on-chain.
| Layer | Technology |
|---|---|
| Frontend | Next.js 15 (App Router), TypeScript, Tailwind CSS |
| UI Components | shadcn/ui |
| Auth | Clerk |
| Database | Neon PostgreSQL via Drizzle ORM |
| File Storage | Pinata (IPFS) |
| Smart Contract | Solidity, Hardhat |
| Blockchain Network | Polygon Amoy Testnet |
| Deployment | Vercel |
Raktbeej/
|- app/ # Next.js App Router pages and API routes
|- components/ # Shared UI components
|- contracts/ # Solidity smart contracts
|- drizzle/ # Drizzle migrations and schema metadata
|- lib/ # Utility libraries (db, pinata, etc.)
|- scripts/ # Hardhat deployment scripts
|- utils/ # Shared helper functions
|- artifacts/ # Hardhat compiled contract artifacts
|- public/ # Static assets
|- drizzle.config.ts # Drizzle config
|- hardhat.config.js # Hardhat network config
|- middleware.ts # Clerk auth middleware
`- next.config.ts # Next.js config
Before starting, make sure you have:
- Node.js v18+ and npm
- A Neon account (PostgreSQL)
- A Pinata account (IPFS uploads)
- A Clerk account (authentication)
- MetaMask or another EVM wallet
- Polygon Amoy testnet POL from the Polygon faucet
git clone https://github.com/hangyakuzero/Raktbeej.git
cd Raktbeejnpm installCreate a .env.local file in the project root:
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
# Neon PostgreSQL
DATABASE_URL=postgresql://user:password@ep-xxx.us-east-1.aws.neon.tech/neondb?sslmode=require
# Pinata
PINATA_JWT=eyJhbGci...
NEXT_PUBLIC_PINATA_GATEWAY=https://gateway.pinata.cloud
# Smart Contract
NEXT_PUBLIC_CONTRACT_ADDRESS=0x...
PRIVATE_KEY=your_wallet_private_keyDo not commit .env.local.
Push schema:
npx drizzle-kit pushGenerate and run migrations if schema changes:
npx drizzle-kit generate
npx drizzle-kit migrateOpen Drizzle Studio:
npx drizzle-kit studioContract file: contracts/Donate.sol
Ensure hardhat.config.js has Polygon Amoy configured and PRIVATE_KEY is set in .env.local.
npx hardhat compilenpx hardhat run scripts/deploy.js --network amoyAfter deployment, copy the contract address into NEXT_PUBLIC_CONTRACT_ADDRESS.
npx hardhat verify --network amoy <CONTRACT_ADDRESS>Development:
npm run devApp URL: http://localhost:3000
Production:
npm run build
npm startLint:
npm run lintVisit /sign-up and create an account through Clerk.
Visit /papers to view uploaded papers and donation options.
Authenticated authors can:
- Upload a PDF to IPFS via Pinata.
- Add collaborator wallet addresses.
- Define royalty splits that add up to 100%.
- Save metadata and splits to Neon.
- Connect wallet on Polygon Amoy.
- Choose a paper and donation amount.
- Confirm transaction.
- Contract distributes funds to all listed wallets.
Visit /About to learn the project background and motivation.
Contributions are welcome.
git checkout -b feature/your-feature-name
git commit -m "feat: add your feature"
git push origin feature/your-feature-nameThen open a pull request with a short summary of what changed and why.
- Better on-chain accounting to reduce donation gas overhead
- Improved author attribution workflow
- Mainnet deployment after more testing
- DAO-based governance
- Multi-chain support
- Pinata and IPFS for decentralized file storage
- Neon for serverless PostgreSQL
- Polygon for EVM-compatible low-cost transactions
- The DeSci community