A blockchain-based clean air incentive system for farmers using zkTLS technology to verify "No Burning" status from government portals.
CleanField addresses the carbon credit and air quality challenge in agricultural regions. Farmers who avoid crop burning receive stablecoin rewards (USDC) based on cryptographically verified data from the Thai Government's GISTDA portal.
- zkTLS Integration: Trustless verification of government portal data
- Smart Contract Insurance: Automated USDC rewards for clean farming
- Admin Dashboard: Monitor all registered farms and burning incidents
- Mobile-First Farmer Interface: Easy access to rewards and payment history
- Sepolia Testnet Deployment: Production-ready smart contracts
- Next.js 15: Full-stack React framework
- TypeScript: Type-safe development
- Tailwind CSS: Utility-first styling
- Mobile-Responsive: Optimized for farm owner mobile access
- Solidity ^0.8.19: Smart contract language
- Foundry: Development framework
- Sepolia Testnet: EVM testnet deployment
- USDC Integration: Stablecoin reward payments
- Primus Network: zkTLS proof generation
- GISTDA Portal: Thai government land use data
- Cryptographic Proofs: Trustless data verification
cleanfield/
├── app/ # Next.js app directory
│ ├── page.tsx # Admin dashboard
│ ├── farm/[id]/page.tsx # Farm owner mobile view
│ └── api/ # API routes
│ ├── farms/route.ts # Get all farms
│ └── farms/[id]/route.ts # Get farm details
├── contracts/ # Foundry smart contracts
│ ├── src/
│ │ ├── CleanFieldOracle.sol # Main insurance contract
│ │ └── utils/Ownable.sol # Access control
│ ├── test/ # Contract tests
│ ├── script/Deploy.s.sol # Deployment script
│ └── foundry.toml # Foundry config
├── lib/
│ ├── types/farm.ts # TypeScript types
│ └── data/mockData.ts # Mock farm data
├── docs/
│ └── zkTLS_INTEGRATION.md # zkTLS integration guide
└── README.md # This file
- Node.js 18+
- npm or yarn
- Foundry (for smart contracts)
- MetaMask or Web3 wallet
- Clone the repository
git clone <repository-url>
cd cleanfield- Install frontend dependencies
npm install- Set up environment variables
cp .env.example .env.localEdit .env.local:
NEXT_PUBLIC_CONTRACT_ADDRESS=<deployed-contract-address>
PRIVATE_KEY=<your-private-key>
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/<your-api-key>
- Install Foundry (if not already installed)
curl -L https://foundry.paradigm.xyz | bash
foundryup- Build smart contracts
cd contracts
forge build- Run contract tests
forge testnpm run devOpen http://localhost:3000 to see the admin dashboard.
Access individual farm views at:
- http://localhost:3000/farm/farm1
- http://localhost:3000/farm/farm2
- http://localhost:3000/farm/farm3
- http://localhost:3000/farm/farm4
- http://localhost:3000/farm/farm5
-
Fund your wallet with Sepolia ETH
- Get testnet ETH from Sepolia Faucet
-
Deploy the contract
cd contracts
forge script script/Deploy.s.sol:DeployCleanFieldOracle --rpc-url $SEPOLIA_RPC_URL --broadcast --verify- Update
.env.localwith contract address
function registerFarm(string memory _farmId, string memory _gistdaId) externalfunction submitProof(
string memory _farmId,
bytes32 _proofHash,
bool _noBurningDetected
) externalfunction claimReward(string memory _farmId) externalSee docs/zkTLS_INTEGRATION.md for detailed zkTLS integration recommendations.
zkTLS enables trustless verification of the "No Burning Detected" status from the Thai Government's GISTDA portal without requiring server modifications.
Integration Points:
- Primary: GISTDA portal status verification
- Secondary: Historical compliance verification
- Advanced: Farm registration and satellite data
-
Farm Registration
- Farm owner registers with farm ID and GISTDA ID
- Smart contract stores farm metadata
-
Monthly Verification
- Oracle generates zkTLS proof from GISTDA portal
- Proof shows "No Burning Detected" status
- Proof submitted to smart contract
-
Reward Distribution
- If no burning detected for 30 days
- Farm owner claims reward (500 USDC)
- Smart contract transfers USDC to owner wallet
-
Ineligibility
- If burning detected (proof shows burning)
- Farm becomes ineligible for that period
- Must wait for clean period to claim again
Returns all registered farms with status information.
Returns specific farm details and payment history.
The project includes mock data for 5 farms:
- farm1: Green Valley Farm (Clean, $500 reward)
- farm2: Sunrise Orchards (Burning detected, ineligible)
- farm3: Golden Harvest Fields (Clean, $800 paid)
- farm4: River Bend Agriculture (Clean, $650 pending)
- farm5: Mountain View Plantation (Burning detected)
cd contracts
forge test -vvvTests cover:
- Farm registration
- Proof submission
- Reward claiming
- Access control
- Edge cases
- Start development server
- View admin dashboard at
/ - Check farm status table
- Navigate to farm owner views (
/farm/farm1, etc.) - Verify payment history display
- Test "Mock Time Change" button
- Deploy CleanFieldOracle contract to Sepolia
- Deploy or use existing USDC contract
- Fund contract with USDC for rewards
- Set oracle address in contract
- Update
NEXT_PUBLIC_CONTRACT_ADDRESSin.env.local - Deploy Next.js app to Vercel/hosting
- Test end-to-end flow on testnet
- Integrate zkTLS SDK (Phase 2)
- ✅ Smart contract infrastructure
- ✅ Admin dashboard
- ✅ Farm owner mobile interface
- ✅ Mock data and API endpoints
- Integrate Primus zkTLS SDK
- GISTDA portal proof generation
- Oracle service implementation
- Real-time proof verification
- Historical compliance verification
- Satellite data integration
- Air quality index verification
- Multi-region support
This is a hackathon project. Contributions and suggestions are welcome!
MIT License
- Primus Labs: https://docs.primuslabs.xyz/
- GISTDA: https://gistda.or.th/
- Foundry: https://book.getfoundry.sh/
- Next.js: https://nextjs.org/
- Sepolia Faucet: https://sepoliafaucet.com/
For questions or demo requests, please reach out during the hackathon.
Built for ETHChaingmai 2026 🌱