The WebSocket API provides real-time order tracking on Solana. For applications that need instant feedback on order status, WebSocket eliminates the latency and overhead of polling.
Why Use WebSocket on Solana?
Solana's fast block times (~400ms) make real-time tracking particularly valuable:
- Instant Notifications - Know immediately when your order is filled
- Transaction Details - Each event includes the Solana transaction signature for verification
- Efficient Monitoring - Track multiple orders with a single connection
Order Events
The Solana WebSocket API provides three event types:
create
Emitted when your escrow transaction is confirmed on-chain. Includes the transaction signature and slot number.
fill
Emitted when a resolver fills your order. Contains the resolver's address and the amounts exchanged.
cancel
Emitted when an order is cancelled, either by the maker or by a resolver cleaning up an expired order.
Interactive Code Example
Explore the complete implementation — this example demonstrates creating an order and tracking it via WebSocket events: