Developer Fundamentals

4. Tx Pool Watch

Listen to unconfirmed tx added to pool; fetch details.

Prerequisites

Pending Tx Pool

Tx gossip! 🗣️ Catch pending before blocks.

const wsUrl = subscriptions.getNewTransactionsSubscriptionUrl('https://mainnet.vechain.org');
const ws = new WebSocket(wsUrl);
ws.onmessage = async (msg) => {
  const txId = JSON.parse(msg.data).id;
  console.log('Pending TxID:', txId);
  // Fetch full: const tx = await thor.transactions.getTransaction(txId);
};
const wsUrl = subscriptions.getNewTransactionsSubscriptionUrl('https://mainnet.vechain.org');
const ws = new WebSocket(wsUrl);
ws.onmessage = async (msg) => {
  const txId = JSON.parse(msg.data).id;
  console.log('Pending TxID:', txId);
  // Fetch full: const tx = await thor.transactions.getTransaction(txId);
};
const wsUrl = subscriptions.getNewTransactionsSubscriptionUrl('https://mainnet.vechain.org');
const ws = new WebSocket(wsUrl);
ws.onmessage = async (msg) => {
  const txId = JSON.parse(msg.data).id;
  console.log('Pending TxID:', txId);
  // Fetch full: const tx = await thor.transactions.getTransaction(txId);
};

Fates: Included, reverted, expired. Proactive alerts for your analytics!
Pool mastered!​

Pitfalls: TxID only—always refetch details.