A comprehensive demonstration of zero-knowledge proof generation and verification using the Reclaim Protocol integrated with the Stellar blockchain. This project showcases how to fetch data from various sources with cryptographic proofs and verify them on-chain using Soroban smart contracts.
This project supports five different data sources for generating zero-knowledge proofs:
- Source: CoinGecko API
- Data: Real-time Stellar (XLM) cryptocurrency price in USD
- Use Case: Cryptocurrency price verification and trading applications
- Source: Trading Economics website
- Data: Countries GDP data and economic indicators
- Use Case: Economic analysis and financial reporting
- Source: Forbes Real-Time Billionaires API
- Data: Live billionaire rankings, names, and net worth
- Use Case: Wealth tracking and financial analytics
- Source: AccuWeather NYC weather page
- Data: Current temperature and city information for New York
- Use Case: Weather verification and climate applications
- Source: Goal.com live scores page
- Data: Live football match scores and team information
- Use Case: Sports betting verification and match tracking
- Zero-Knowledge Proof Generation: Generate cryptographic proofs for external API data
- Stellar Blockchain Integration: Verify proofs on Stellar testnet using Soroban contracts
- Multi-Source Data Support: Five different data sources with unique extraction patterns
- Comprehensive Testing: Full test suite with utility function validation
- Modern Development Setup: ESLint, Prettier, and automated testing
- CLI Interface: Easy-to-use command-line interface for all operations
- Node.js >= 18.0.0
- npm or yarn package manager
- Stellar testnet account with XLM for transaction fees
- Basic understanding of blockchain and zero-knowledge proofs
-
Clone the repository
git clone https://github.com/your-username/zkfetch-stellar-example.git cd zkfetch-stellar-example
-
Install dependencies
npm install
-
Download required ZK files
npm run download-zk-files
-
Set up environment variables
cp .env.example .env # Edit .env file with your Stellar seedphrase
-
Run setup script (optional)
npm run setup
Create a .env
file in the project root:
# Stellar Wallet Configuration
SEEDPHRASE=your twelve word seedphrase goes here for stellar wallet generation
# Optional: Override default network settings
# NETWORK_URL=https://horizon-testnet.stellar.org
# SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
# CONTRACT_ID=CB5MLBRA5FOCU4ZE557UKHYIKA6ASE6U6ZNK4WVBMWZ7G6IOQMSSWCXQ
The application uses a centralized configuration system in src/config.js
:
- Reclaim Protocol: APP_ID and APP_SECRET for proof generation
- Stellar Network: Testnet configuration and contract details
- API Endpoints: CoinGecko API for price data
- File Paths: Default locations for proof files
# Generate a new Stellar price proof
npm run request-proof
# Generate a new Trading Economics countries GDP proof
npm run request-trading-economics
# Generate a new Forbes billionaires proof
npm run request-forbes
# Generate a new AccuWeather NYC proof
npm run request-accuweather
# Generate a new Goal.com live scores proof
npm run request-goal
# Verify existing proof on blockchain
npm run verify-proof
# Run complete workflow (request + verify)
npm start workflow
# Display application information
npm start info
import { ZkFetchStellarApp } from './src/index.js';
const app = new ZkFetchStellarApp();
// Request a new Stellar price proof
const stellarProof = await app.requestStellarPriceProof();
// Request a new Trading Economics countries GDP proof
const tradingEconomicsProof = await app.requestTradingEconomicsProof();
// Request a new Forbes billionaires proof
const forbesProof = await app.requestForbesProof();
// Request a new AccuWeather NYC proof
const accuWeatherProof = await app.requestAccuWeatherProof();
// Request a new Goal.com live scores proof
const goalProof = await app.requestGoalProof();
// Verify proof on blockchain
const txHash = await app.verifyProofOnStellar();
// Run complete workflow
const result = await app.runCompleteWorkflow();
import { requestProof } from './src/requestProof.js';
import { verifyProof } from './src/verifyProof.js';
// Request Stellar price proof with custom output path
const stellarProof = await requestProof('./stellar-proof.json', 'stellar');
// Request Trading Economics proof with custom output path
const tradingEconomicsProof = await requestProof('./trading-economics-proof.json', 'trading-economics');
// Request Forbes proof with custom output path
const forbesProof = await requestProof('./forbes-proof.json', 'forbes');
// Request AccuWeather proof with custom output path
const accuWeatherProof = await requestProof('./accuweather-proof.json', 'accuweather');
// Request Goal.com proof with custom output path
const goalProof = await requestProof('./goal-proof.json', 'goal');
// Verify proof with custom file path
const txHash = await verifyProof('./custom-proof.json');
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
- Proof Structure Validation: Validates proof format and required fields
- Signature Verification: Ensures cryptographic signatures are valid
- Utility Function Tests: Tests all helper functions with edge cases
- Configuration Tests: Validates application configuration
zkfetch-stellar-example/
├── src/
│ ├── config.js # Centralized configuration
│ ├── index.js # Main application entry point
│ ├── requestProof.js # Proof generation module
│ ├── verifyProof.js # Blockchain verification module
│ ├── utils.js # Utility functions
│ └── proof.json # Generated proof file
├── tests/
│ └── proof.test.js # Comprehensive test suite
├── scripts/
│ └── setup.js # Setup automation script
├── .env.example # Environment variables template
├── .eslintrc.json # ESLint configuration
├── .prettierrc # Prettier configuration
├── .gitignore # Git ignore rules
└── package.json # Project dependencies and scripts
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Check formatting
npm run format:check
npm start
- Run main applicationnpm run request-proof
- Generate new proofnpm run verify-proof
- Verify existing proofnpm test
- Run test suitenpm run test:watch
- Run tests in watch modenpm run test:coverage
- Run tests with coveragenpm run lint
- Lint codenpm run lint:fix
- Fix linting issuesnpm run format
- Format codenpm run setup
- Run setup script
- Network: Testnet
- Horizon URL: https://horizon-testnet.stellar.org
- Soroban RPC: https://soroban-testnet.stellar.org
- Contract ID: CCDFS3UOSJOM2RWKVFLT76SIKI3WCSVSFUGX24EL4NXVISFOFQB37KKO
- Explorer: https://stellar.expert/explorer/testnet/
- CoinGecko Stellar Price: https://api.coingecko.com/api/v3/simple/price?ids=stellar&vs_currencies=usd
- Trading Economics Countries: https://tradingeconomics.com/
- Forbes Billionaires: https://www.forbes.com/forbesapi/person/rtb/0/-estWorthPrev/true.json?fields=rank,personName,finalWorth
- AccuWeather NYC: https://www.accuweather.com/en/us/new-york/10021/weather-forecast/349727
- Goal.com Live Scores: https://www.goal.com/en-in/live-scores
The application uses the Reclaim Protocol to generate zero-knowledge proofs for multiple data sources:
- API Request: Fetches data from the selected source (CoinGecko, Trading Economics, Forbes, AccuWeather, or Goal.com)
- Data Extraction: Uses specialized regex patterns to extract relevant information from each source
- Proof Generation: Creates cryptographic proof of the extracted data
- File Storage: Saves proof to JSON file
The verification process submits proofs to the Stellar blockchain:
- Proof Loading: Reads and validates proof file
- Data Preparation: Formats proof data for blockchain submission
- Transaction Creation: Builds Stellar transaction with Soroban contract call
- Blockchain Submission: Signs and submits transaction to testnet
The application interacts with a Soroban smart contract that:
- Verifies cryptographic signatures
- Validates proof structure
- Stores verification results on-chain
-
Missing .env file
cp .env.example .env # Edit with your seedphrase
-
Insufficient XLM balance
- Ensure your Stellar testnet account has XLM for transaction fees
- Get testnet XLM from Stellar Friendbot
-
ZK files not downloaded
npm run download-zk-files
-
Network connection issues
- Check internet connection
- Verify Stellar testnet is accessible
Missing required environment variables
: Check your .env fileProof file not found
: Runnpm run request-proof
firstFailed to create Stellar wallet
: Verify your seedphrase formatTransaction failed
: Check account balance and network status
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
- Reclaim Protocol for zero-knowledge proof infrastructure
- Stellar Development Foundation for blockchain platform
- CoinGecko for cryptocurrency price data
- Trading Economics for economic data
- Forbes for billionaires data
- AccuWeather for weather data
- Goal.com for sports data
- Soroban for smart contract platform
- Repository: https://github.com/your-username/zkfetch-stellar-example
- Issues: https://github.com/your-username/zkfetch-stellar-example/issues
- Stellar Explorer: https://stellar.expert/explorer/testnet/
- Reclaim Protocol: https://reclaimprotocol.org/