Skip to content

Latest commit

Β 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— Chainlink CRE Integration ⚑

Production-Ready Workflow

Directory: satellite-oracle/

We've implemented a complete Chainlink Runtime Environment workflow using the official SDK.

Quick Overview

  • Data Source: NASA FIRMS VIIRS satellite (375m resolution)
  • Update Frequency: Every 3 hours via cron trigger
  • Region: South Asia (6-37Β°N, 68-98Β°E) - configurable
  • Filtering: High-confidence fires only (β‰₯80%)
  • Delivery: Multi-node consensus via CRE's consensusAggregationByFields

Implementation

Main Workflow: satellite-oracle/src/main.ts

import { Runtime, Trigger } from '@chainlink/cre-sdk';

export async function main(trigger: Trigger, runtime: Runtime): Promise<void> {
  // Fetch NASA satellite data
  const response = await runtime.httpClient.get(nasaFirmsUrl);
  
  // Parse and validate
  const fires = parseCSV(response.data).filter(f => f.confidence >= 80);
  
  // Deliver with consensus
  await runtime.consensusAggregationByFields({
    contractAddress: '0x4FC34fdB6244007436D8edDD7311f099D61E97E6',
    data: encodeWildfireData(fires),
    methodSignature: 'pushWildfireData(...)',
  });
}

Simulation Results

$ cre workflow simulate production-settings

βœ“ Fetched 8 fire detections from NASA FIRMS
βœ“ Filtered to 6 high-confidence fires (β‰₯80%)
βœ“ Consensus aggregation: SUCCESS
βœ“ Would deliver to oracle: 0x4FC34fdB6244007436D8edDD7311f099D61E97E6
βœ“ Status: READY FOR DEPLOYMENT

Deployment Status

Current: ⏳ Awaiting CRE deployment access (Early Access)

When access granted:

cre workflow deploy satellite-oracle --target production-settings

See CRE_WORKFLOW_DOCUMENTATION.md for complete technical details.# πŸ›°οΈ Satellite Oracle Network

Chainlink CRE-powered oracle network for parametric insurance using real-time satellite data

Chainlink Tenderly Solidity

🎯 Overview

This project brings real-world satellite data onchain for automated parametric insurance payouts. Using NASA FIRMS (wildfire detection) and Copernicus Sentinel Hub (vegetation health), we create verifiable data feeds that trigger smart contract actions when events are detected.

Use Case: A farmer purchases wildfire insurance. When NASA satellites detect a fire in their covered region with high confidence, the smart contract automatically pays out - no claims process, no delays.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              CHAINLINK CRE WORKFLOW (workflow.ts)            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  handler(trigger, callback) {                                β”‚
β”‚    Capability.http.fetch  β†’  NASA FIRMS API                 β”‚
β”‚    Capability.evm.write   β†’  SatelliteOracle contract       β”‚
β”‚  }                                                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           TENDERLY VIRTUAL TESTNET (Chain ID: 9991)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  SatelliteOracle      β†’      WildfireInsurance              β”‚
β”‚  (Receives data)             (Auto-triggers payouts)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

torq/
β”œβ”€β”€ contracts/                    # Solidity smart contracts
β”‚   β”œβ”€β”€ SatelliteOracle.sol      # Core oracle for satellite data
β”‚   β”œβ”€β”€ WildfireInsurance.sol    # Parametric insurance contract
β”‚   └── interfaces/              # Contract interfaces
β”œβ”€β”€ workflow.ts                   # πŸ”— REAL CRE workflow (TypeScript SDK)
β”œβ”€β”€ scripts/                      # Deployment & simulation scripts
β”‚   β”œβ”€β”€ deploy.js                # Deploy to Tenderly/local
β”‚   └── simulate.js              # E2E workflow simulation
β”œβ”€β”€ test/                         # Contract tests
β”œβ”€β”€ workflows/                    # Legacy workflow files (for reference)
β”œβ”€β”€ ARCHITECTURE.md              # Technical architecture docs
β”œβ”€β”€ REAL_CRE_GUIDE.md            # CRE implementation guide
β”œβ”€β”€ UPDATED_EXECUTION_PLAN.md    # Execution plan
β”œβ”€β”€ DEMO.md                      # Demo guide
β”œβ”€β”€ SUBMISSION.md                # Hackathon submission
└── README.md                    # This file

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm

Installation

# Clone the repository
git clone <your-repo-url>
cd torq

# Install dependencies
pnpm install

Compile Contracts

pnpm run compile

Run Tests

pnpm run test

Run CRE Workflow Tests

pnpm run cre:test

🎨 Professional Frontend

A complete insurance platform interface has been built with professional styling:

Features

  • Professional Design - Blue, white, and black insurance theme
  • Web3 Integration - MetaMask wallet connection & smart contract interaction
  • Policy Management - Create, view, and manage insurance policies onchain
  • Real-time Monitoring - NASA FIRMS satellite fire detection dashboard
  • Responsive Design - Works on desktop, tablet, and mobile
  • Automated Claims - One-click claim processing with instant payouts

Run Frontend Demo

# Navigate to frontend
cd frontend

# Option 1: Simple server
python -m http.server 8000

# Option 2: Full server with mock APIs
npm install
npm start

# Open browser
open http://localhost:8000

Demo Flow (Perfect for Hackathon)

  1. Backend Demo (3 min): Show CRE workflow simulation and Tenderly transactions
  2. Frontend Demo (5 min): Professional UI, wallet connection, policy creation, real-time monitoring
  3. Claims Demo (2 min): Automatic fire detection β†’ instant payout demonstration

Total presentation time: 10 minutes with professional visuals

Deploy to Tenderly Virtual TestNet

  1. Create a Tenderly Virtual TestNet

    • Go to Tenderly Dashboard
    • Create a new Virtual TestNet (fork Ethereum Mainnet)
    • Copy the RPC URL
  2. Configure Environment

    cp .env.example .env
    # Edit .env with your Tenderly RPC URL and private key
  3. Deploy

    pnpm run deploy:tenderly
  4. Run Simulation

    pnpm run simulate

Deployed Contracts (Tenderly Virtual TestNet)

Contract Address
SatelliteOracle 0x4FC34fdB6244007436D8edDD7311f099D61E97E6
WildfireInsurance 0xb4dfecdcA79E1577D6C15560450b5881CF610bE9

πŸ”— Chainlink CRE Workflow

We've implemented a real CRE workflow using the official Chainlink Runtime Environment SDK pattern.

File: workflow.ts

import { Trigger, Workflow, Capability } from '@chainlink/cre-sdk';

export const handler: Workflow.Handler = async (trigger, callback) => {
  // Step 1: Fetch wildfire data using official CRE HTTP capability
  const fires = await Capability.http.fetch('https://firms.modaps.eosdis.nasa.gov/api/...');
  
  // Step 2: Deliver to oracle using official CRE EVM capability
  const tx = await Capability.evm.write({
    contractAddress: '0x4FC34fdB6244007436D8edDD7311f099D61E97E6',
    functionName: 'deliverWildfireData',
    args: [latitudes, longitudes, brightness, confidences]
  });
  
  return callback.success({ fireCount: fires.length, txHash: tx.hash });
};

export const metadata: Workflow.Metadata = {
  name: 'nasa-firms-wildfire-detector',
  triggers: [{ type: 'cron', schedule: '0 */3 * * *' }],
  capabilities: ['http.fetch', 'evm.write']
};

Key CRE Features Used:

  • βœ… handler(trigger, callback) pattern
  • βœ… Capability.http.fetch for external API calls
  • βœ… Capability.evm.write for blockchain writes
  • βœ… metadata export with triggers and capabilities
  • βœ… Cron trigger (every 3 hours)

Note: CRE is currently in Early Access. When cre CLI becomes available, deploy with cre deploy --network testnet.

πŸ“ Smart Contracts

SatelliteOracle.sol

Core oracle contract that receives and stores verified satellite data.

Key Functions:

  • requestWildfireData(BoundingBox area) - Request wildfire data for a geographic area
  • pushWildfireData(WildfireData[] data) - Push verified satellite data (CRE only)
  • checkActiveFire(BoundingBox area, uint256 minConfidence) - Check for active fires
  • getFiresInArea(BoundingBox area, uint256 maxResults) - Get fire detections in an area

WildfireInsurance.sol

Parametric insurance contract with automatic payouts.

Key Functions:

  • createPolicy(BoundingBox area, uint256 duration, uint256 threshold) - Create insurance policy
  • autoProcessClaim(uint256 policyId) - Auto-process claim based on oracle data
  • fileClaim(uint256 policyId) - Manually file a claim

πŸ”— Data Sources

Source Data Type Update Frequency API
NASA FIRMS Wildfire Detection Every 3 hours FIRMS API
Sentinel Hub Vegetation (NDVI) Daily Sentinel Hub
NOAA Weather Data Hourly weather.gov

πŸ§ͺ Testing

# Run all contract tests
pnpm run test

# Run CRE workflow capability tests
pnpm run cre:test

# Run with verbose output
npx hardhat test --verbose

πŸ“Š Hackathon Submission

Requirements Checklist

  • Smart contracts for satellite data oracle
  • Parametric insurance with automatic payouts
  • Deployment scripts for Tenderly Virtual TestNet
  • Simulation scripts demonstrating full workflow
  • Comprehensive test suite
  • CRE workflow implementation
  • Tenderly Explorer deployment
  • Video demonstration

Key Innovation

  1. Real Satellite Data: Using actual NASA/ESA satellite feeds for verifiable event detection
  2. Parametric Insurance: No claims process - automatic payouts when conditions are met
  3. CRE Integration: Chainlink Runtime Environment for secure, verifiable data delivery
  4. Tenderly Testing: Full testing with mainnet-synced state

πŸ” Security

  • Only authorized data deliverer can push oracle data
  • Confidence thresholds prevent false positives
  • Time-bounded fire detections (24-hour validity)
  • Owner-controlled parameter updates

πŸ“„ License

MIT

🀝 Contributing

This project was built for the Chainlink Block Magic Hackathon 2026.


Built with ❀️ for the Chainlink Hackathon

About

This project brings real-world satellite data onchain for automated parametric insurance payouts. Using NASA FIRMS (wildfire detection) and Copernicus Sentinel Hub (vegetation health), we create verifiable data feeds that trigger smart contract actions when events are detected.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages