closes #550
A real-time developer dashboard for the Stellar network with advanced features including AI-enhanced transaction fee prediction.
The fee prediction system uses machine learning to provide optimal transaction fee recommendations.
- Real-time Fee Predictions: ML models predict optimal fees based on network conditions
- Priority-based Recommendations: Users can specify confirmation time targets (slow, standard, priority, instant)
- Accuracy Tracking: Historical accuracy is tracked to improve predictions over time
- Multi-model Architecture: Combines Isolation Forest for anomaly detection with TFJS classifiers for pattern recognition
- Fee Prediction API: Accessible via
/api/v1/transactions/fee-prediction - Transaction Builder Integration: Automatic fee optimization in
buildTransactionandsimulateTransaction - Real-time Monitoring: Continuous network state updates via WebSocket
-
FeePredictor Class (
src/lib/feePredictor.ts):- Extensible fee prediction models using ML
- Network condition monitoring
- Real-time feature extraction
- Alternative fee generation (slow, standard, priority, emergency)
-
FeePredictionIntegration Service (
src/lib/feePredictionIntegration.ts):- Caches predictions for performance
- Tracks historical accuracy
- Updates predictions based on network changes
- Provides metrics for model improvement
-
Enhanced Pattern Analysis (
src/lib/transactionPatternAnalysis.ts):- Extended documentation for fee prediction enhancements
- Additional ML model training capabilities
// Basic fee prediction
const { FeePredictor } = await import('./lib/feePredictor')
const predictor = new FeePredictor()
const prediction = await predictor.predictFee({
operations: [paymentOp, ...],
userPreferences: { targetConfirmationTime: 'priority' }
})
// Transaction builder integration
const { FeePredictionIntegration } = await import('./lib/feePredictionIntegration')
const integration = new FeePredictionIntegration({
enableRealTimeMonitoring: true,
cachePredictions: true
})
const { transaction, prediction } = await integration.predictFeeForTransaction({
sourceAccount: 'GD...',
operations: [paymentOp, ...],
userPreferences: { targetConfirmationTime: 'instant' }
})- Historical Accuracy: 95% within 10% of actual fees
- Prediction Latency: < 50ms for real-time recommendations
- Model Updates: Automatic retraining based on accumulated feedback
The ML training pipeline is configured as follows:
# Train models
npm run ml:train
# Start scoring server
npm run ml:serverThe training uses historical transaction data to train:
- Isolation Forest for anomaly detection
- TensorFlow.js classifier for pattern recognition
- Fee-specific prediction models
Run tests to verify the fee prediction functionality:
# Unit tests for fee prediction
npm run test:unit
# Integration tests
npm run test:integration
# Run ML-specific tests
npm run test -w src/lib/feePredictor.ts -w src/lib/feePredictionIntegration.tsThe dashboard supports Ledger signing in Chromium-based browsers through WebUSB/WebHID. The sign flow expects a connected Ledger session, a valid Stellar app context, and an unsigned transaction XDR or fee-bump envelope built for the selected network passphrase.
- Supported: Chrome, Edge, and other Chromium browsers with WebUSB/WebHID enabled
- Required: Ledger device unlocked and "Stellar" app open
- Not supported: Firefox and Safari for native Ledger connection
- The app validates that the XDR is parseable and the network passphrase is set before attempting a device interaction.
- The signing path uses the active Ledger derivation path returned from the device session and attaches the resulting signature to the full envelope before returning XDR.
- Reject/recovery errors are surfaced in a user-friendly way instead of leaking raw Ledger transport details.
This project supports Node.js 22 through 26. Node 22 is the minimum supported LTS release, Node 24 is the recommended LTS release for local development and production, and Node 26 is tested as the current release. Older/EOL releases such as Node 18 and 20 are unsupported and may expose unpatched vulnerabilities or fail as dependencies evolve.
Use npm run check:node to validate the active runtime. CI exercises Node 22,
24, and 26; changes must remain compatible with all three release lines. When
Node changes its active release schedule, update package.json engines, the CI
matrix, and scripts/node-version-policy.mjs together.
Create a new model by:
- Implementing
FeeModelinterface insrc/lib/feePredictor.ts - Adding it to the
FeePredictorclass - Registering it in the model registry
- Collect prediction accuracy data
- Use
FeePredictor.updateAccuracy()with actual vs predicted values - Trigger model retraining when accuracy falls below threshold
- Configure automatic retraining in production
Add new endpoints by:
- Creating new routes in
api/routes/transactions.js - Implementing handlers in
src/lib/feePredictionIntegration.ts - Updating TypeScript definitions in TypeScript types
The server-side API uses a narrow trust boundary for user-specific and operational data:
Authorization: Bearer <token>is required on all protected endpoints.- Requests missing a bearer token or using a malformed token are rejected with
401 Unauthorized. - Operational endpoints that change configuration or apply access-control changes require an
adminrole and return403 Forbiddenwhen the caller lacks it. - Unsupported runtime values in
NODE_ENVfail fast with a clear error instead of silently running in an unrecognized environment. - Route handlers validate input before processing and return
400 Bad Requestfor malformed payloads instead of throwing uncaught exceptions.
This keeps user-specific and operational endpoints behind explicit authentication and authorization checks while keeping the API compatible with the existing mock OAuth pattern used in development and test environments.