A decentralised crop insurance platform built on the Solana blockchain. Farmers can register, pay premiums, and file claims — with all payments recorded immutably on-chain and farmer profiles stored in Supabase.
Live Deployment: https://block-harvest-qk3j.vercel.app/
This is a Next.js project bootstrapped with create-next-app.
- Farmers connect their Phantom wallet and register with their name, crop type, and land size
- Premium payments (0.1 SOL) are transferred on-chain to a program vault and recorded immutably
- Claims are filed and approved by an admin wallet, releasing SOL back to the farmer
- Every transaction is publicly verifiable on Solana Explorer
- Farmer profile data is stored in Supabase for fast, flexible display
| Layer | Technology |
|---|---|
| Smart contract | Rust, Anchor 0.29.0 |
| Blockchain | Solana Devnet |
| Frontend | Next.js 15, TypeScript, Tailwind CSS |
| Wallet | Phantom via Solana Wallet Adapter |
| Database | Supabase (PostgreSQL) |
| JS client | @coral-xyz/anchor 0.29.0, @solana/web3.js |
blockHarvest/
└── block-harvest/
├── programs/
│ └── block-harvest/
│ └── src/
│ └── lib.rs # Anchor smart contract
├── app/ # Next.js frontend
│ ├── app/
│ │ ├── layout.tsx # Root layout
│ │ ├── providers.tsx # Wallet provider wrapper
│ │ ├── page.tsx # Landing + wallet connect
│ │ ├── register/
│ │ │ └── page.tsx # Farmer registration form
│ │ └── dashboard/
│ │ └── page.tsx # Farmer dashboard + pay premium
│ └── lib/
│ ├── anchor.ts # Anchor client + PDA helpers
│ └── supabase.ts # Supabase client + types
├── Anchor.toml # Anchor config
└── Cargo.toml # Rust workspace
Program ID: C54J4haBjNNGYfV8ZENqvDRzvhX5ReeJPjyCVnySbdXj
Network: Solana Devnet
Framework: Anchor 0.29.0
| Instruction | Who can call | What it does |
|---|---|---|
register_farmer |
Any wallet | Creates a PDA account tied to the farmer's wallet |
pay_premium |
Registered farmer | Transfers 0.1 SOL to vault, marks premium_paid = true |
file_claim |
Admin only | Marks claim_filed = true on farmer's account |
approve_claim |
Admin only | Releases SOL from vault back to farmer's wallet |
farmer Pubkey wallet address
premium_paid bool whether premium has been paid
premium_amount u64 amount paid in lamports
payment_timestamp i64 unix timestamp of payment
claim_filed bool whether a claim has been filed
claim_approved bool whether the claim was approved
bump u8 PDA bump seed
Farmer PDA → seeds: ["farmer", wallet_address]
Vault PDA → seeds: ["vault"]
- Rust 1.85+
- Solana CLI 3.x
- Node.js 20+
- Anchor CLI 0.29.0
- Phantom browser extension
git clone https://github.com/yourname/block-harvest.git
cd block-harvestrustup default stable
rustup updatesolana config set --url devnet
solana-keygen new --outfile ~/.config/solana/id.json
# Get free SOL at https://faucet.solana.comanchor buildanchor deploy --provider.cluster devnetcd app
npm installCreate .env.local:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
NEXT_PUBLIC_PROGRAM_ID=C54J4haBjNNGYfV8ZENqvDRzvhX5ReeJPjyCVnySbdXj
NEXT_PUBLIC_RPC_URL=https://api.devnet.solana.comRun this in the Supabase SQL editor:
create table farmers (
wallet_address text primary key,
name text not null,
crop_type text not null,
land_size numeric not null,
created_at timestamp with time zone default now()
);
alter table farmers disable row level security;npm run dev1. Open app → connect Phantom wallet
2. First time? → redirected to /register
3. Fill in name, crop type, land size → submit
- Creates on-chain PDA account
- Saves profile to Supabase
4. Redirected to /dashboard
- Profile loaded from Supabase
- Payment status loaded from chain
5. Click "Pay Premium — 0.1 SOL"
- Phantom prompts for approval
- 0.1 SOL transferred to vault PDA
- premium_paid = true stored on-chain
- Transaction link shown (Solana Explorer)
6. Admin can file and approve claims
- SOL released back to farmer wallet
Every premium payment produces a transaction signature. Paste it into:
https://explorer.solana.com/tx/<SIGNATURE>?cluster=devnet
You will see:
- The program that was called (
block_harvest) - The instruction (
pay_premium) - SOL transferred from farmer wallet to vault
premium_paid = truewritten to the farmer's PDA account
This is the tamper-proof payment record — no database, no admin, no server can alter it.
- Anchor 0.29.0 is required for Rust and the JS client — do not mix versions
- The Solana platform tools ship their own Cargo; if you see edition2024 errors, delete
~/.cache/solana/and let it re-download - The
pubkey!()macro is not available in Anchor 0.29.0 — admin is compared using.to_string() - Wallet adapter components require a
mountedguard in Next.js to avoid hydration errors
Built as a college showcase project to demonstrate real-world use of the Solana blockchain for agricultural insurance use cases.