Decentralized Infrastructure for Agricultural Commerce & Governance
A single on-chain-anchored platform for crop trade, price transparency, tool sharing, and agricultural governance.
Overview • Modules • Architecture • Getting Started • Environment • Database • Contracts • Roadmap • Contributing
AgriChain is a production blockchain-backed platform built to remove intermediaries from agricultural commerce and give farmers direct market access, verifiable transaction history, and a voice in agricultural policy through on-chain elections.
Every transaction — a crop sale, a tool rental, a vote — is written to chain and mirrored in a relational data layer for fast querying, giving the platform both the auditability of a blockchain and the performance of a conventional application.
Status: Active development — pre-launch. Interfaces and contract addresses in this document are subject to change until v1.0.0.
| Module | Description |
|---|---|
| 🛒 Direct Crop Marketplace | Farmers list crops directly to buyers/merchants, cutting out middlemen. |
| 📊 Real-Time Price Analytics | Live market pricing to help farmers time sales and negotiate fairly. |
| 🔗 On-Chain Transactions | Crop and tool-rental payments recorded on Ethereum/Solana with tx_hash provenance. |
| 🔧 Peer-to-Peer Tool Rentals | Farmers list and rent equipment (Lessor/Lessee roles) without third-party platforms. |
| 🗳️ On-Chain Agricultural Voting | State-level, tamper-proof voting for Agriculture Minister elections. |
┌───────────────────────────┐
│ Client (Web) │
│ Next.js App Router + TS │
│ Tailwind CSS UI │
└──────────────┬─────────────┘
│
REST / Server Actions
│
┌──────────────▼─────────────┐
│ Application Layer │
│ Next.js Route Handlers │
└──────┬─────────────────┬────┘
│ │
┌───────────▼───────┐ ┌─────▼──────────────┐
│ PostgreSQL │ │ Blockchain Layer │
│ Users · Crop · │ │ Solidity (EVM) / │
│ Tools · Transaction│ │ Solana Programs │
└────────────────────┘ └─────────────────────┘
- Off-chain (PostgreSQL): user profiles, role data (Lessor/Lessee/Merchant), crop and tool listings, cached analytics.
- On-chain (Ethereum/Solana): transaction settlement,
tx_hashprovenance, voting ballots. - Every
TRANSACTIONrecord links an off-chain row to its on-chain proof, so the UI stays fast while remaining independently verifiable.
Core entities, with role-based inheritance:
User
├── Lessor (lists Tools for rent)
├── Lessee (rents Tools)
└── Merchant (buys/sells Crop)
Crop
├── owner_id → User
├── price
└── listing_status
Tools
├── lessor_id → User
├── availability
└── rental_rate
Transaction
├── type (crop_sale | tool_rental)
├── ref_id → Crop.id | Tools.id
├── from_user_id → User
├── to_user_id → User
├── amount
├── tx_hash (on-chain proof)
├── chain (ethereum | solana)
└── status (pending | confirmed | failed)
Full ERD available in
/docs/erd.md.
| Layer | Technology |
|---|---|
| Framework | Next.js (App Router) |
| Language | TypeScript |
| Styling | Tailwind CSS |
| Database | PostgreSQL |
| Smart Contracts | Solidity (EVM), Solana Programs (Rust) |
| Auth | (fill in — e.g. NextAuth / custom JWT) |
| Hosting | (fill in — e.g. Vercel + Railway/Supabase) |
- Node.js ≥ 18.x
- PostgreSQL ≥ 14
- pnpm / npm / yarn
- A funded wallet + RPC endpoint for testnet deployment (Ethereum Sepolia / Solana Devnet)
# Clone the repository
git clone https://github.com/<your-org>/agrichain.git
cd agrichain
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env.local
# Run database migrations
npm run db:migrate
# Start the development server
npm run devThe app will be available at http://localhost:3000.
Create a .env.local file with the following:
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/agrichain
# Blockchain — Ethereum
NEXT_PUBLIC_ETH_RPC_URL=
ETH_PRIVATE_KEY=
CONTRACT_ADDRESS_ETH=
# Blockchain — Solana
NEXT_PUBLIC_SOLANA_RPC_URL=
SOLANA_PROGRAM_ID=
# Auth
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3000Never commit
.env.local. Rotate any keys that were ever pushed to a public branch.
| Contract / Program | Chain | Purpose | Address |
|---|---|---|---|
AgriTransaction |
Ethereum | Crop & tool-rental settlement | TBD |
AgriVote |
Ethereum / Solana | State-level Agriculture Minister voting | TBD |
Contract source lives under /contracts. Deployment scripts under /scripts/deploy.
# Compile contracts
npm run contracts:compile
# Run contract tests
npm run contracts:test
# Deploy to testnet
npm run contracts:deploy -- --network sepolianpm run test # unit tests
npm run test:e2e # end-to-end tests
npm run contracts:test # smart contract tests- Core ERD: User, Lessor, Lessee, Merchant, Tools, Crop
-
TRANSACTIONentity for on-chain payment logging - Dark, soil-themed UI system
- Wallet connect (MetaMask / Phantom)
- Real-time price analytics dashboard
- On-chain voting module (testnet)
- Security audit of smart contracts
- Mainnet deployment
This is currently a closed-development startup repository. If you've been granted access:
- Create a feature branch:
git checkout -b feature/your-feature - Commit with clear messages:
git commit -m "feat: add crop listing pagination" - Open a pull request against
mainwith a description and testing notes.
Proprietary — All rights reserved, © 2026 AgriChain. (Replace with MIT/Apache-2.0 if open-sourcing.)
Built by Sunny Rai — shipping real infrastructure, not tutorials.