mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
One toolchain across the estate. The tree carried 1.26.0, .1, .3, .4 and .5 at once, so which compiler built a binary depended on which repo it came from. Co-authored-by: Hanzo Dev <[email protected]>
Example 02: AI-Powered Payment Validation
This example demonstrates how AI consensus validates cross-chain payments before execution.
What It Shows
- AI agent analyzing payment requests
- Confidence scoring for transactions
- Fraud detection using AI
- Learning from payment outcomes
Run the Example
cd examples/02-ai-payment
go run main.go
Run the Tests
go test -v
Expected Output
=== AI Payment Validation ===
Payment Request #1:
Amount: 1000 LUX
From: ethereum
To: lux
AI Analysis:
✓ Confidence: 0.92 (HIGH)
✓ Risk Level: LOW
✓ Decision: APPROVE
Reasoning: Normal transaction pattern, amount within limits
Payment Request #2:
Amount: 50000 LUX
From: ethereum
To: lux
AI Analysis:
⚠ Confidence: 0.45 (LOW)
⚠ Risk Level: HIGH
✗ Decision: REJECT
Reasoning: Unusual amount, potential fraud
=== Learning from Outcomes ===
✓ AI updated with 2 training examples
✓ Model weights adjusted based on feedback
Key Concepts
- AI Decision Making: Agent analyzes payment before execution
- Confidence Scoring: Determines how sure the AI is
- Risk Assessment: Identifies potentially fraudulent transactions
- Continuous Learning: Improves from successful/failed payments
Integration Pattern
// 1. Create AI agent for payment validation
agent := ai.NewAgent(nodeID, model, quasar, photon)
// 2. Analyze payment request
decision, err := agent.ProposeDecision(ctx, txData, context)
// 3. Check confidence threshold
if decision.Confidence < 0.7 {
// Reject low-confidence payments
return errors.New("confidence too low")
}
// 4. Learn from outcome
agent.AddTrainingData(example)
Play With It
Try modifying:
- Confidence thresholds
- Risk assessment criteria
- Training data feedback
- Transaction patterns