In a live fintech system serving 1M+ users, we faced a critical issue where blockchain transactions started failing randomly.

At first, everything looked normal:

  • RPC provider was stable
  • Blockchain network was healthy
  • Backend APIs were working

But transactions were still failing intermittently with almost no useful error logs.

The Real Problem

Before-fix transaction flow showing parallel workers independently generating conflicting nonces and causing blockchain rejections
The Real Problem: parallel transaction flows were producing nonce conflicts.

The Real Problem: Nonce Issue

Our logs only showed:

“Transaction Failed”

No RPC details. No blockchain error context.

This made debugging extremely difficult.

What We Discovered

After improving logging, we finally saw the real error:

nonce mismatch / nonce too low / replacement transaction error

Root Cause

The issue came from nonce desynchronization in our blockchain wallet system.

Why it happened:

  • Multiple background workers
  • Retry system re-submitting transactions
  • Admin cancellation flow
  • Parallel transaction processing

This caused multiple workers to generate conflicting nonces.

In simple terms: Two or more transactions were trying to use the same “sequence number”, and the blockchain rejected them.

What is a Nonce (Simple Explanation)

Sequential wallet transaction nonces 10, 11, and 12 contrasted with an invalid sequence gap that a blockchain rejects
Blockchain transactions from a wallet must follow a strict, continuous nonce sequence.

In blockchain systems, a nonce is a sequential number assigned to each transaction from a wallet.

Think of it like a queue number:

  • Transaction 1 → nonce 10
  • Transaction 2 → nonce 11
  • Transaction 3 → nonce 12

Blockchain expects this sequence to be strict and continuous.

If order breaks → transaction is rejected.

Why Nonce is Important

Nonce ensures:

  • Transactions are processed in correct order
  • No duplicate transactions
  • Wallet state consistency
  • Protection against replay or conflicts

Even a small mismatch can block all future transactions.

What Went Wrong in Our System

Our system had multiple parallel components:

  • Background workers
  • Retry system
  • Admin cancellation flow
  • Multiple cron jobs

This caused:

  • Multiple workers generating transactions at the same time
  • Retry sending old transactions again
  • Nonce values getting reused or skipped

Result: Two transactions ended up using the same nonce → blockchain rejected them.

Root Cause (Simple)

We had no centralized nonce management.

Each worker was generating nonce independently, which created race conditions in a distributed system.

The Fix

After-fix transaction architecture with all workers requesting a nonce from a shared Redis manager before sending transactions to the RPC provider
After the fix: workers share a centralized nonce state and submit transactions in order.

We implemented a Redis-based centralized nonce manager:

  • Redis acts as single source of truth
  • Atomic increment ensures safe nonce generation
  • All workers share same state
  • No duplicate nonce possible

Now flow looks like:

Worker → Redis (get + increment nonce) → RPC → Blockchain
Redis nonce manager flow: workers request and atomically increment a shared nonce before calling the RPC provider and blockchain
Redis-based centralized nonce manager

Result

  • Transaction failures dropped to near zero
  • Retry system became stable
  • Workers fully synchronized
  • Production system stabilized quickly

Key Learnings

  • Logging is critical in distributed systems
  • Blockchain transactions require strict state control
  • Parallel workers must share state (not local memory)
  • Retry systems can silently introduce complex bugs
  • Small race conditions can become major production incidents

Final Thought

In distributed fintech systems, even a simple concept like “sequence number” can become a system-critical failure point if not centrally controlled.

This incident reinforced one thing: Always design state carefully in distributed systems.