A transparent agricultural supply chain platform
Batches registered on-chain with purchases via Stripe; a verifier account transfers ownership on-chain after payment.
The following technologies power FarmLedge, along with their icons and usage:
Frontend
Backend
Utilities & DevOps
| Technology | Icon | Usage |
|---|---|---|
| npm | Dependency management and scripts. | |
| GitHub Actions | CI/CD workflows for automated testing and deployment. | |
| Docker (opt.) | Containerization for consistent environments. |
🎯 Key Features
- INR-Only On-Chain Pricing
Set farm-gate, distributor, and retailer prices in rupees—all stored on the blockchain. - Off-Chain Payments with Stripe
Secure checkout and webhooks trigger ownership transfers. - Verifier-Based Transfers
Only approved relayers can calltransferOwnershipByVerifier. - Lean Reads & Fast UI
Recent batches timeline with search, skeleton loaders, and detail modals. - Idempotent Webhooks
Automatic duplicate-write protection (handles nonce errors).
� Verifier UX & Workflow (Latest)
- Themed Verify Modal
Verifiers get a themed dialog to confirm and enter a passkey before marking a batch as Verified. - Search & Sorting on Verifier Dashboard
Quickly filter byID,crop, orholderand sort byID,quantity, orcrop(asc/desc). Verified batches remain hidden. - One-way Verification Rules
Verified items cannot be edited; only allowed transitions betweenunverifiedandpendingbefore final verify. - i18n Coverage
English, Tamil, Hindi, and Odia across Navigation, Hero, Login, Index, and Verifier flows.
�📦 Prerequisites
- Node.js ≥ 18
- npm
- Stripe test account (API keys)
- Arbitrum Sepolia RPC URL + funded relayer private key
- Deployed AgriTruthChain contract address
🔧 Local Setup
# Clone the repo
git clone https://github.com/blackscythe123/FarmLedge.git
cd FarmLedge
# Install dependencies
npm install
cd server && npm install && cd ..
# Configure environment
cp server/.env.example server/.env
# Populate server/.env:
# STRIPE_SECRET_KEY=sk_test_...
# STRIPE_WEBHOOK_SECRET=whsec_...
# PORT=3001
# AGRI_TRUTH_CHAIN_ADDRESS=0xYourDeployedContract
# RELAYER_PRIVATE_KEY=your_funded_sepolia_private_key
# OWNER_PRIVATE_KEY=optional_owner_key_for_verifier_setup
# ARB_SEPOLIA_RPC_URL=https://sepolia-rollup.arbitrum.io/rpc
# Start backend & frontend
npm run server:dev # runs backend on port 3001
npm run dev # runs frontend on port 8000Open http://localhost:8000 in your browser.
🔑 One-Time Verifier Setup
curl -X POST http://localhost:3001/api/setup-relayer-as-verifieror if native binary not working
Invoke-RestMethod -Method Post -Uri http://localhost:3001/api/setup-relayer-as-verifier | ConvertTo-Json -Depth 6Response returns a transaction hash on success.
🔄 Core Flows
- Register Batch
POST/api/register-batch→ writes batch + farmer price on-chain. - Purchase
- Create Stripe session: POST
/create-checkout-session - On webhook, server calls
transferOwnershipByVerifierand optionally sets next price.
- Create Stripe session: POST
- View Batches
- GET
/api/batches→ list of batches with computed fallbacks & timestamps - GET
/api/batch/:id→ detailed batch info
- GET
- Price Updates
- Distributor: POST
/api/set-price-by-distributor - Retailer: POST
/api/set-price-by-retailer
- Distributor: POST
- Fallback
POST/api/confirm-paymentif webhook fails.
📑 API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /create-checkout-session |
Returns Stripe session ID & URL |
| POST | /api/register-batch |
Register new batch on-chain |
| GET | /api/batches |
List all batches |
| GET | /api/batch/:id |
Get batch details |
| POST | /api/confirm-payment |
Manual fallback transfer |
| POST | /api/set-price-by-distributor |
Set distributor price |
| POST | /api/set-price-by-retailer |
Set retailer price |
| POST | /api/setup-relayer-as-verifier |
Mark relayer as verifier (one-time) |
| GET | /api/chain-info |
Dev diagnostics |
ℹ️ API Documentation Link
The footer "API Documentation" link points to this README’s API section on GitHub:
https://github.com/blackscythe123/FarmLedge#api-endpoints
🎨 Frontend Highlights
- Recent Batches Timeline
Paginated view (3 per page), searchable by Batch ID on Index. Status badges (Unverified/Pending/Verified) visible. - Verifier Dashboard
Search + sort controls, themed verification modal with passkey, and strict one-way transitions. - Footer Resources
Includes a GitHub link to the repo and API Documentation linking back to this README’s API section.
🛠️ Scripts
- Webhook Signature Errors
EnsureSTRIPE_WEBHOOK_SECRETmatches your Stripe CLI/webhook config. - Contract Address Issues
VerifyAGRI_TRUTH_CHAIN_ADDRESSpoints to your deployed contract (not an EOA). - Relayer Setup
ConfirmRELAYER_PRIVATE_KEYhas sufficient Sepolia ETH. - Pricing Mismatch
Stripe sends amounts in paise; contract stores rupees—convert appropriately.
🔒 Security & Data
- On-Chain: Public data (batch IDs, owners, INR prices)
- Off-Chain: Minimal session & role data; Stripe handles payment details
- Idempotency: Webhooks are idempotent to avoid duplicate blockchain writes