Cardano zkFetch Integration
Guide for using zkFetch with Cardano blockchain data and services
Cardano zkFetch Integration
Overview
zkFetch for Cardano enables developers to fetch data from external APIs with cryptographic proof of execution, storing verifiable proofs on the Cardano blockchain. This integration allows for trustless data verification without revealing sensitive information like API keys or private parameters.
Key Features
- Zero-Knowledge Proofs: Generate proofs of API execution without revealing private data
- Cardano Integration: Store proof identifiers and extracted data on Cardano blockchain
- Testnet Support: Full Preprod testnet compatibility for development and testing
- Metadata Storage: Leverage Cardano's transaction metadata for proof storage
System Architecture
Workflow Architecture
- Proof Generation Phase
- Client initiates zkFetch request with public and private parameters
- Reclaim Protocol executes API call through witness network
- Zero-knowledge proof is generated containing response data
- Proof includes extracted parameters while hiding sensitive data
- Cardano Integration Phase
- Proof identifier and extracted data are prepared for on-chain storage
- Transaction is constructed with proof data in metadata
- Transaction is submitted to Cardano network (Preprod/Mainnet)
- Proof becomes permanently verifiable on-chain
- Verification Phase
- Third parties can verify proofs using Reclaim SDK
- On-chain data provides immutable record of proof existence
- Extracted parameters are publicly accessible via transaction metadata
Quickstart
If you prefer to quickly try the integration, this section is for you. First, make sure you have Node.js and Deno installed.
Step 1: Clone repository and install packages:
Step 2: Create a wallet and fund it:
Details will be written to addressDetails.json
, you can get Preprod funds from the faucet.
Step 3: Request a proof with zkFetch:
The proof will be written to proof.json
.
Step 4: Send transaction to Preprod:
Proof identifier and extracted parameters will be included in the transaction's metadata.
Testing
Run all tests with:
Also, you can test wallet creation separately with:
Or proof requesting with:
Prerequisites and Setup
System Requirements
- Node.js: Version 16+
- Deno: Latest stable version
- Cardano Wallet: For transaction signing and ADA funds
- API Access: Reclaim Protocol credentials and Blockfrost API key
Environment Setup
-
Install Dependencies
-
Configure Environment Variables
-
Obtain Credentials
- Reclaim Protocol: Register at Reclaim Developer Portal
- Blockfrost: Get API key from Blockfrost.io
Deployment Guide
Step 1: Wallet Creation and Funding
Create a Cardano wallet for transaction signing:
Fund the wallet using the Cardano Testnet Faucet.
Step 2: Configure zkFetch Client
Step 3: Deploy to Cardano Network
The deployment involves setting up your application to interact with both the Reclaim Protocol and Cardano network simultaneously.
Integration Steps
1. Initialize zkFetch Integration
2. Configure API Request
3. Execute zkFetch Request
4. Prepare Transaction for Cardano
5. Submit Transaction to Cardano
zkFetch Module Interactions
Core Modules
1. Proof Generation Module
2. Cardano Integration Module
3. Verification Module
Module Integration Flow
API Reference
ReclaimClient Methods
zkFetch(url, publicOptions, privateOptions?, retries?, retryInterval?)
Executes a verified fetch request with zero-knowledge proof generation.
Parameters:
url
(string): Target API endpointpublicOptions
(object): Request parameters visible in proofprivateOptions
(object): Hidden request parametersretries
(number): Number of retry attempts (default: 1)retryInterval
(number): Retry delay in milliseconds (default: 1000)
Returns: Promise
Public Options Structure
Private Options Structure
Cardano Integration Methods
Transaction Metadata Schema
Example Implementations
Basic Price Oracle
Sports Data Integration
Authentication-Required API
Troubleshooting
Common Issues
1. Proof Generation Failures
Problem: zkFetch request fails with timeout or network errors Solution:
- Increase retry attempts and interval
- Verify API endpoint accessibility
- Check response matching patterns
2. Transaction Submission Errors
Problem: Cardano transaction fails to submit Solution:
- Verify wallet has sufficient ADA balance
- Check transaction size limits
- Validate metadata structure
3. Proof Verification Failures
Problem: Proof verification returns false Solution:
- Ensure proof object is complete
- Check witness signatures
- Verify timestamp validity
Debug Mode
Enable detailed logging for troubleshooting:
Security Considerations
Best Practices
- Private Key Management
- Never expose wallet private keys in code
- Use environment variables for sensitive data
- Implement proper key rotation for production
- API Key Protection
- Store API keys in privateOptions only
- Regularly rotate API credentials
- Monitor API usage for anomalies
- Proof Validation
- Always verify proofs before trusting data
- Implement additional business logic validation
- Check proof timestamps for freshness
- Network Security
- Use HTTPS endpoints only
- Validate SSL certificates
- Implement rate limiting
For additional support and updates, refer to: