The application was getting stuck at "Tracing Origins" phase with no feedback about what was happening. Users couldn't see:
- Which wallet was being traced
- What API calls were being made
- How deep the trace was going
- Where the process was stuck
Added comprehensive logging throughout the entire token tracing process.
- Added
logCallbackparameter - Created
log()method to output messages
Analyzing DEX transactions from block X to Y...
Found N total transactions (X sells, Y buys)
=== Tracing sell #1/3: 0x1234...5678 ===
[Detailed trace logs...]
=== Completed trace #1/3 ===
Each depth level shows:
[Depth 0] Tracing wallet 0x1234...5678 at block 36230305
[Depth 0] Searching for first incoming transfer to 0x1234...5678...
Searching blocks 36229305-36230305 for 0x1234...5678...
Found 2 incoming transfer(s) for 0x1234...5678
[Depth 0] Found transfer from 0xabcd...ef01 at block 36229800
[Depth 0] → Recursively tracing 0xabcd...ef01...
[Depth 1] Tracing wallet 0xabcd...ef01 at block 36229800
[Depth 1] Searching for first incoming transfer to 0xabcd...ef01...
Searching blocks 36228800-36229800 for 0xabcd...ef01...
No transfers found in this range, searching earlier blocks...
Searching blocks 36227800-36228799 for 0xabcd...ef01...
Found 1 incoming transfer(s) for 0xabcd...ef01
[Depth 1] Found transfer from 0xdex0...pool at block 36228100
[Depth 1] ✓ Source is origin: dex (0xdex0...pool)
[Depth N] ✓ Origin found: dex (0x1234...5678)
[Depth N] ✓ Source is origin: contract (0xabcd...ef01)
[Depth N] ⚠ Already processed 0x1234...5678, stopping trace
[Depth N] ⚠ Max depth reached for 0x1234...5678
[Depth N] ⚠ No incoming transfers found for 0x1234...5678
Searching blocks 36229305-36230305 for 0x1234...5678...
Found 2 incoming transfer(s) for 0x1234...5678
No transfers found in this range, searching earlier blocks...
Searching blocks 36228305-36229304 for 0x1234...5678...
Search exhausted for 0x1234...5678 (searched 50 chunks)
[Depth N] ❌ Error tracing 0x1234...5678: [error message]
12:33:28 PM - Tracing Origins
Found 3 sell transaction(s) to trace
[Nothing more... appears frozen]
12:33:28 PM - Tracing Origins
Found 3 sell transaction(s) to trace
12:33:29 PM - Token Tracer
Analyzing DEX transactions from block 36230305 to 36230305...
12:33:29 PM - Token Tracer
Found 3 total transactions (3 sells, 0 buys)
12:33:29 PM - Token Tracer
=== Tracing sell #1/3: 0x1234...5678 ===
12:33:29 PM - Token Tracer
[Depth 0] Tracing wallet 0x1234...5678 at block 36230305
12:33:29 PM - Token Tracer
[Depth 0] Searching for first incoming transfer to 0x1234...5678...
12:33:30 PM - Token Tracer
Searching blocks 36229305-36230305 for 0x1234...5678...
12:33:31 PM - Blockchain API
API Call: eth_getLogs for blocks 36229305-36229314 (10 blocks)
12:33:32 PM - Blockchain API
Received 5 transfer events (filtering zero-value)
... [continues with detailed progress]
- Transparency: Users see exactly what's happening
- Debugging: Easy to identify where process is slow or stuck
- Trust: Shows the app is working, not frozen
- Performance Insight: Can see which operations take time
- Error Identification: Quickly spot where failures occur
-
src/utils/tracker.ts
- Added
logCallbackparameter to constructor - Added
log()method - Added
depthparameter totraceToOrigin() - Added logging at every major step
- Added logging in
findFirstIncomingTransfer() - Added logging in
analyzeAndTrace()
- Added
-
src/components/AnalysisForm.tsx
- Pass log callback to TokenTracker constructor
- [Depth N]: Shows recursion depth (0 = original seller)
- ✓: Success/completion
- ⚠: Warning/limitation reached
- ❌: Error occurred
- →: Recursive call
- Indented: Sub-operations (like block searches)
Minimal - logging only adds string operations and state updates. The actual blockchain queries remain the same.
Test scenarios:
- ✅ Trace that reaches DEX pool origin
- ✅ Trace that reaches token contract origin
- ✅ Trace with multiple hops (depth > 1)
- ✅ Trace that hits max depth
- ✅ Trace with no incoming transfers found
- ✅ Multiple sells being traced sequentially
=== Tracing sell #1/3: 0x1234...5678 ===
[Depth 0] Tracing wallet 0x1234...5678 at block 36230305
[Depth 0] Searching for first incoming transfer to 0x1234...5678...
Searching blocks 36229305-36230305 for 0x1234...5678...
Found 1 incoming transfer(s) for 0x1234...5678
[Depth 0] Found transfer from 0xabcd...ef01 at block 36229800
[Depth 0] → Recursively tracing 0xabcd...ef01...
[Depth 1] Tracing wallet 0xabcd...ef01 at block 36229800
[Depth 1] Searching for first incoming transfer to 0xabcd...ef01...
Searching blocks 36228800-36229800 for 0xabcd...ef01...
Found 1 incoming transfer(s) for 0xabcd...ef01
[Depth 1] Found transfer from 0xpool...addr at block 36228900
[Depth 1] ✓ Source is origin: dex (0xpool...addr)
=== Completed trace #1/3 ===
This shows:
- Starting trace for seller
- Searching for where they got tokens
- Found they received from another wallet
- Recursively trace that wallet
- Found that wallet received from DEX pool
- Origin identified as DEX
- Trace complete
Users now have complete visibility into the tracing process, making it clear the app is working and showing exactly what it's doing at each step.