-
Notifications
You must be signed in to change notification settings - Fork 19
Description
📌 Overview
Finance and accounting teams require access to gas usage data in a structured, portable format for reconciliation and analysis. Manual extraction is time-consuming and prone to errors.
This task introduces a CSV Export for Gas Usage, allowing authorized users to download detailed gas spending reports for further processing.
🎯 Objective
Build a system that:
- Exports gas usage data per merchant or wallet
- Provides detailed chain-level and transaction-level breakdowns
- Generates CSV files in a standard format for finance teams
- Supports filtering by date range, chain, or transaction type
🛠 Scope of Work
1️⃣ Data Aggregation
-
Collect relevant transaction and gas usage data:
- Transaction hash
- Gas used and gas price
- Chain ID / name
- Timestamp
- Wallet / merchant ID
- Cost in ETH / native token and USD equivalent
-
Support filtering by:
- Date range (daily, weekly, monthly)
- Merchant or wallet
- Chain
2️⃣ CSV Generation
- Format data into a standard CSV structure:
- Column headers consistent across exports
- Include optional metadata (report generation timestamp, filters applied)
- Handle large datasets efficiently:
- Streaming CSV generation to reduce memory usage
Example CSV headers:
MerchantID,Wallet,Chain,TxHash,GasUsed,GasPriceETH,GasCostETH,GasCostUSD,Timestamp
3️⃣ API Endpoints
Expose endpoints to generate and download CSV exports:
GET /exports/gas-usage?merchantId=&from=&to=
GET /exports/gas-usage/:wallet/download
- Support authenticated access via API key or JWT
- Return file as attachment with proper content type (
text/csv) - Include error handling for invalid filters or empty datasets
4️⃣ Security & Access
- Only authorized users (merchant, admin, finance role) can download exports
- Optional logging for all export requests for audit purposes
🧰 Suggested Tech Stack
Core
- TypeScript
- Node.js
- Express / Fastify / NestJS
- PostgreSQL (transaction and gas usage data)
- fast-csv or similar library for CSV generation
Optional Enhancements
- Redis (cache commonly requested exports)
- Email delivery of CSV reports (optional)
- Prometheus metrics for export usage
- Jest (unit testing)
🧠 Implementation Expectations
- Clear separation between:
- Data aggregation layer
- CSV generation module
- API delivery layer
- Efficient handling of large datasets using streaming
- Unit tests covering:
- Data aggregation correctness
- CSV formatting and structure
- API endpoint functionality and security
📊 Deliverables
- CSV export generation module
- API endpoints for on-demand export and download
- Documentation explaining:
- CSV format and columns
- Filtering options
- Authentication and access
- Unit tests (minimum 70% coverage)
- Updated README
🏷 Difficulty Level
Intermediate
Ideal for contributors with:
- Backend TypeScript experience
- Knowledge of CSV generation and large dataset handling
- API design and security awareness
- Multi-chain transaction data understanding
🕒 Estimated Time
12hrs (part-time contributor)
✅ Acceptance Criteria
- CSV correctly generated with all required fields
- Filters and date ranges work accurately
- API endpoints return downloadable CSV files
- Authorized access enforced
- Documentation updated
- All tests passing
🎯 Expected Outcome
GasGuard provides downloadable gas usage reports, empowering finance teams with actionable data, reducing manual effort, and enabling accurate reconciliation and analysis.