Dexploit is in public beta. Share feedback →

Skip to content
← Back to Blog
solanawallet-trackingwebsockettutorial

How to Follow a Solana Wallet's Swaps in Real Time

Dexploit Team··7 min read
How to Follow a Solana Wallet's Swaps in Real Time

You have a Solana wallet address and you want to see what it does: each buy and sell, as it happens. Dexploit's swaps WebSocket can filter by wallet, so following one or several wallets is about forty lines of Node. This tutorial also covers the REST routes for a wallet's history, and what a wallet feed can and can't tell you.

It uses a Free key: 10 requests per second, 10,000 requests a month, 14 days of history, one stream at a time (authentication). Get a key from the dashboard.

Read this first: what a wallet feed shows

  • It shows swaps by the wallet you name. The filter matches each swap's trader, which is the transaction's fee payer. For swaps routed through an aggregator such as Jupiter, the fee payer may not be the wallet you think it is, depending on how the app built the transaction (wallet filter example).
  • It shows what happened, not why. A swap is a trade on an indexed DEX. Plain transfers between wallets are not part of this feed.
  • One person can use many wallets. Dexploit does not link wallets together, so a feed for one address shows only that address.

Two ways to follow a wallet

FilterRoom
Howsubscribe with filters: { traders: [...] }join the room wallet:<address>
WalletsMany in one subscriptionOne per room
Combine withmin_sol, dexes, tokens, is_buyNothing: it delivers every swap by that wallet
Frame shapeA plain swap frameThe same swap, wrapped in { type: "message", room, data }

Both worked on a Free key. A connection uses a filter or rooms, not both. This tutorial uses the filter, because it follows several wallets at once and lets you add a size threshold.

Setup

mkdir follow-wallet && cd follow-wallet
npm init -y
npm install ws
export DEXPLOIT_API_KEY=your-key-here

The scripts use .mjs files and the built-in fetch, so you need Node 18 or newer.

Step 1: stream the swaps

Save this as follow.mjs:

import WebSocket from "ws";

const KEY = process.env.DEXPLOIT_API_KEY;
const wallets = process.argv.slice(2);
if (wallets.length === 0) {
  console.error("usage: node follow.mjs <wallet> [<wallet> ...]");
  process.exit(1);
}
const MIN_SOL = Number(process.env.MIN_SOL ?? 0); // optional: only swaps of at least this many SOL

const short = (s) => s.slice(0, 6) + "…" + s.slice(-4);
const ws = new WebSocket("wss://ws.dexploit.dev/ws/swaps", {
  headers: { Authorization: `Bearer ${KEY}` },
});

let ready = false; // ignore swaps until the server confirms the filter

ws.on("open", () => {
  const filters = { traders: wallets };
  if (MIN_SOL > 0) filters.min_sol = Math.round(MIN_SOL * 1e9); // min_sol is in lamports
  ws.send(JSON.stringify({ type: "subscribe", filters }));
});

ws.on("message", (raw) => {
  const msg = JSON.parse(raw.toString());
  if (msg.type === "subscribed" && msg.message === "Filter updated") {
    ready = true;
    console.log(`Following ${wallets.length} wallet(s)…`);
    return;
  }
  if (!ready || msg.type !== "swap") return;

  const time = new Date(msg.timestamp * 1000).toISOString().slice(11, 19); // timestamp is in seconds
  const tags = (msg.maker_tags ?? []).join(",") || "-";
  console.log(
    `${time}Z ${short(msg.trader)} ${msg.swap_type.toUpperCase().padEnd(4)} ` +
      `${(msg.sol_amount / 1e9).toFixed(3)} SOL  ${short(msg.token_mint)}  on ${msg.dex}  [${tags}]`,
  );
});

setInterval(() => {
  if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: "ping" }));
}, 30000);

ws.on("close", (code) => console.log("closed", code));
ws.on("error", (err) => console.error("error:", err.message));

Run node follow.mjs <WALLET> with one or more addresses. A live run printed:

Following 2 wallet(s)…
04:35:29Z 8L2y55…bt8j BUY  0.002 SOL  5u5L4o…dYoh  on meteora_damm_v2  [-]
04:35:29Z 8L2y55…bt8j SELL 0.002 SOL  TTWofw…FbKo  on meteora_dlmm  [-]

What the code relies on, all checked against the live feed:

  • ready flag. The server sends "Filter updated" once your filter is applied. The script ignores swaps until then, so nothing from before the filter slips through.
  • Units. sol_amount is in lamports, so divide by 1e9. timestamp is epoch seconds. swap_type is the string "buy" or "sell".
  • maker_tags lists the classifications Dexploit assigned to the trader at swap time, such as sniper, insider or whale. They are automated labels of past behaviour, not accusations. An empty list means none applied.
  • MIN_SOL adds min_sol to the filter, so only swaps of at least that size arrive: MIN_SOL=1 node follow.mjs <WALLET>. The API takes lamports, which is why the code multiplies by 1e9.

A busy wallet can send a lot. In a 90-second test with six wallets from the live feed, one of them produced 619 swaps. Bots do this. Use MIN_SOL or the dexes filter to cut the volume.

Step 2: add the wallet's history

The stream starts at the moment you connect. For what a wallet did before that, use REST. Save this as history.mjs:

const KEY = process.env.DEXPLOIT_API_KEY;
const wallet = process.argv[2];
if (!wallet) {
  console.error("usage: node history.mjs <wallet>");
  process.exit(1);
}
const headers = { "X-API-Key": KEY };

async function get(path) {
  const res = await fetch("https://api.dexploit.dev" + path, { headers });
  if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
  return res.json();
}

// the wallet's recent swaps, newest first, plus a lifetime stats block
const { swaps, stats } = await get(`/swaps/trader/${wallet}?limit=5`);
console.log("lifetime:", stats.total_swaps, "swaps,", stats.total_buys, "buys,", stats.total_sells, "sells,", stats.unique_tokens, "tokens");
for (const s of swaps) {
  // REST uses is_buy (true/false) and timestamp in milliseconds
  console.log(new Date(s.timestamp).toISOString(), s.is_buy ? "BUY " : "SELL", `${(s.sol_amount / 1e9).toFixed(3)} SOL`);
}

// our wallet classifications (sniper, bot, whale, ...)
const { tags } = await get(`/wallets/${wallet}/tags`);
console.log("tags:", [...new Set(tags.map((t) => t.tag))].join(", ") || "none");

A live run for a very active wallet printed:

lifetime: 1932559 swaps, 963213 buys, 969346 sells, 44636 tokens
2026-11-12T04:36:14.000Z SELL 0.002 SOL
2026-11-12T04:36:13.000Z SELL 0.002 SOL
2026-11-12T04:36:13.000Z BUY  0.002 SOL
tags: mev, arbitrage, smart_money, bot, sniper, bundler

The REST routes name things differently from the stream. A few gotchas, all checked on the live API:

FieldWebSocketREST
Buy or sellswap_type is "buy" or "sell"is_buy is true or false
Timetimestamp in secondstimestamp in milliseconds
Wallettraderuser

The stats block is the wallet's lifetime totals, refreshed on a schedule, so it can lag a little behind the swap list (reference). The tags are Dexploit's automated classification of a wallet's behaviour. They describe patterns, such as high swap frequency, and say nothing about who owns the wallet or what they intend.

Things worth knowing before you build on it

  • Free means one stream. A second connection with the same key is refused until the first closes (streaming caps). Put every wallet you follow into one traders list.
  • How soon a swap reaches you depends on your network and host. Measure it from where you will run the code.
  • Only SOL-quoted swaps are indexed (coverage).
  • Reconnects: a dropped connection needs a new subscribe. See Reconnect and backpressure.

Next