Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Grainzy - Grant Execution Infrastructure

Automated, verifiable payments for open-source contributions

Grainzy is a comprehensive grant execution layer that converts ecosystem funding into automated, verifiable payments for open-source contributions. Built on Stellar Soroban, it ensures transparent, escrow-backed payouts based on real GitHub activity.

License: MIT TypeScript Next.js Soroban

🎯 The Problem

Open-source ecosystems face critical challenges:

  • ❌ Grant money managed off-chain with no transparency
  • ❌ Manual distribution of rewards by maintainers
  • ❌ Delayed or subjective contributor payments
  • ❌ No verifiable proof of how grants convert to real work
  • ❌ Contributors must trust platforms or maintainers for fair payouts

✨ Our Solution

Grainzy bridges ecosystems and contributors with an automated, on-chain execution layer:

  • βœ… Escrow-first: Funds locked in smart contracts before work begins
  • βœ… Automated payouts: Triggered by verified GitHub activity
  • βœ… Transparent impact: Every payment is verifiable on-chain
  • βœ… GitHub-native: Works with existing workflows
  • βœ… Privacy-safe: KYC handled off-chain

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Ecosystem     │────▢│ Program Escrow  │────▢│    Project      β”‚
β”‚  (Stellar)      β”‚     β”‚   (Contract)    β”‚     β”‚  Maintainer     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β”‚   Fund (XLM/tokens)   β”‚   Allocate funds      β”‚   Create issues
         │──────────────────────▢│──────────────────────▢│──────────────
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Grainzy Backend                              β”‚
β”‚  β€’ GitHub webhook integration  β€’ Scoring engine                β”‚
β”‚  β€’ Off-chain verification       β€’ KYC management               β”‚
β”‚  β€’ Payout orchestration         β€’ Auditing                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β”‚ Auto-trigger
                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Bounty Escrow (Contract)                         β”‚
β”‚            β€’ Hold individual bounty funds                        β”‚
β”‚            β€’ Enforce max claimants                               β”‚
β”‚            β€’ Platform fee collection                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β”‚ Release
                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Contributor Wallet                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Repository Structure

grainzy/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ contracts/          # Soroban smart contracts (Rust)
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ lib.rs                 # Main exports
β”‚   β”‚   β”‚   β”œβ”€β”€ grainzy_core.rs        # Upgradeable contract
β”‚   β”‚   β”‚   β”œβ”€β”€ program_escrow.rs      # Program-level escrow
β”‚   β”‚   β”‚   └── bounty_escrow.rs       # Individual bounty escrow
β”‚   β”‚   β”œβ”€β”€ manifests/                 # Machine-readable manifests
β”‚   β”‚   β”‚   β”œβ”€β”€ grainlify-core-manifest.json
β”‚   β”‚   β”‚   β”œβ”€β”€ program-escrow-manifest.json
β”‚   β”‚   β”‚   └── bounty-escrow-manifest.json
β”‚   β”‚   β”œβ”€β”€ Cargo.toml
β”‚   β”‚   └── scripts/validate-manifests.sh
β”‚   └── ui/                 # Shared UI components
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ backend/           # Express.js + TypeScript API
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ models/           # Database models (Prisma)
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/           # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ github.ts     # GitHub webhook handler
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ scoring.ts    # Points calculation
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ kyc.ts        # KYC orchestration
β”‚   β”‚   β”‚   β”‚   └── payout.ts     # Payout execution
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   └── utils/
β”‚   β”‚   └── package.json
β”‚   └── webapp/            # Next.js frontend
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ app/              # App Router pages
β”‚       β”‚   β”œβ”€β”€ components/       # React components
β”‚       β”‚   β”‚   β”œβ”€β”€ HeroSection.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ ProgramList.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ HowItWorks.tsx
β”‚       β”‚   β”‚   └── Navbar.tsx
β”‚       β”‚   β”œβ”€β”€ lib/             # Utilities
β”‚       β”‚   └── types/           # TypeScript definitions
β”‚       └── package.json
β”œβ”€β”€ package.json
β”œβ”€β”€ turbo.json            # Turborepo configuration
└── tsconfig.json

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • Rust 1.75+ (for contracts)
  • PostgreSQL 14+
  • Stellar CLI (for deployment)

Install Dependencies

# Install all workspaces
npm install

# Or install individually
npm --workspace=@grainzy/backend install
npm --workspace=@grainzy/webapp install

Set Up Environment

# Backend
cd apps/backend
cp .env.example .env
# Fill in your values

Run Development Servers

# Start all services (requires Turborepo)
npm run dev

# Or individually:
npm --workspace=@grainzy/backend run dev   # Backend on :3001
npm --workspace=@grainzy/webapp run dev    # Frontend on :3000

Build Smart Contracts

cd packages/contracts
cargo build --target wasm32-unknown-unknown --release

Validate Contract Manifests

cd packages/contracts
./scripts/validate-manifests.sh

πŸ”§ Core Contracts

1. GrainzyContract (Upgrade Manager)

  • Time-delayed upgrades (default 24h)
  • Multisig governance (configurable threshold)
  • Immutable upgrade history
  • WASM hash verification

2. ProgramEscrowContract (Hackathon/Grant Programs)

  • Locks program funds in escrow
  • Allocates to projects
  • Processes contributor payouts
  • Emergency pause functionality

3. BountyEscrowContract (Individual Issues)

  • Per-bounty escrow
  • Multi-token support
  • Platform fee collection
  • Claim approval workflow

πŸ” Security Model

  • No on-chain identities: Only wallet addresses stored
  • Off-chain KYC: Compliance handled separately
  • Circuit breakers: Pause contracts during incidents
  • Reentrancy protection: All state changes before external calls
  • Time-locked upgrades: Prevent rapid malicious updates

πŸ“Š Scoring Algorithm

Points awarded based on:

  1. Base points (assigned by maintainer)
  2. Complexity multiplier (PR size)
  3. Reputation bonus (contributor history)
  4. Capped maximum per PR

Formula: FinalPoints = min(Base Γ— Complexity Γ— Reputation, MAX_PER_PR)

πŸ”— GitHub Integration

Webhooks received for:

  • Issues β†’ Sync bounty point assignments
  • Pull Requests β†’ Link to issues, track status
  • Reviews β†’ Auto-approval logic
  • Pushes β†’ Trigger merge detection

🌐 Deployment

Smart Contracts (Soroban)

# Deploy upgrade contract first
stellar contract deploy \
  --wasm target/wasm32-unknown-unknown/release/grainzy_contracts.wasm \
  --source <admin-keypair> \
  --network testnet

# Then deploy Program Escrow
# Then deploy Bounty Escrow

Backend (Heroku/Railway/DigitalOcean)

cd apps/backend
npm run build
npm start

Frontend (Vercel/Netlify)

cd apps/webapp
npm run build
# Deploy output folder

πŸ§ͺ Testing

# Run backend tests
npm --workspace=@grainzy/backend run test

# Run contract tests
npm run contracts:test

# End-to-end simulation (TODO)
npm run test:e2e

πŸ“– Documentation

🀝 Contributing

We welcome contributions! Please see our Contributing Guide.

Development Workflow

  1. Fork the repository
  2. Create feature branch: git checkout -b feat/my-feature
  3. Commit changes: git commit -am 'Add feature'
  4. Push branch: git push origin feat/my-feature
  5. Open a Pull Request

πŸ“œ License

MIT License - see LICENSE for details.

πŸ™ Acknowledgments

πŸ“ž Contact


Built with ❀️ for open source maintainers and contributors worldwide.

About

Grainzy is a grant execution infrastructure designed to automate how open-source funding is distributed, verified, and settled.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages