In this note
  1. 01On-Chain Layer
  2. 02Off-Chain Pipeline
  3. 03Risk and Notification
  4. 04Knowledge Points
  5. 05Takeaway

The Anchor program is the part people ask about. The rest of the system is about what happens after a transaction lands.

Solana OrderFlow has two halves. On chain, an Anchor program owns the escrow state and the tokens. Off chain, services read the program logs, normalize them, publish to Kafka, write Postgres, and run the consumer workflows.

On-Chain Layer

Three instructions cover the flow: create an offer, take an offer, cancel an offer. Creating one moves tokens into a vault token account tied to that offer. Filling or canceling empties that vault, and the program authorizes the transfer with PDA signer seeds instead of a private key.

The escrow account holds the maker address, the mint accounts, the requested amount, the offered amount, the status, and the bump. Status is Created, Filled, or Cancelled, and the transition is explicit, which matters in a flow that moves money.

Off-Chain Pipeline

The listener opens a WebSocket subscription to program logs, turns each JSON-like message into an event record, and publishes it to Kafka. A storage writer consumes the events and writes two tables: an append-only event table and an offer snapshot table.

The split earns its keep. Events keep history; the snapshot keeps queries cheap. The writer also uses idempotent keys and commits Kafka offsets by hand, so a failed database write leaves the event available for retry instead of dropping it or counting it twice.

Risk and Notification

The risk engine reads the same stream and applies rules. Large offer amounts and repeated cancels are the two it starts with. Alerts go to their own topic, so notification code can change without touching detection.

Knowledge Points

  • An escrow program is easier to review when custody and state transitions are explicit.
  • PDA signer seeds let a program move tokens out of accounts it owns without holding a private key.
  • Program logs are the practical bridge between on-chain execution and off-chain indexing.
  • Partition keys, idempotent producers, and manual commits are the parts of a Kafka pipeline that decide whether it stays correct under retries.
  • Append-only events plus snapshot tables are the usual event-sourcing shape behind a dashboard.
  • Amounts crossing a language boundary need care, because a JavaScript number cannot hold every token amount exactly.
  • A risk engine can start with rules and move to scoring later.

Takeaway

The contract is one layer. Ingestion, storage, idempotency, monitoring, and downstream consumers are the rest, and each of them can fail on its own.