Skip to Content
Pulsar Solana Standalone

Using Solana Trackers Standalone

While the Pulsar suite offers a full stack solution with a UI (@tuwaio/nova-transactions) and a Zustand-based state store (@tuwaio/pulsar-core), its architecture remains modular and flexible. This allows utilizing the low-level trackers (solanaFetcher) from @tuwaio/pulsar-solana directly, bypassing the complete state management store.

This flexibility is ideal if:

  • Integrating transaction tracking logic into your own state management solution (Zustand, Redux, MobX, etc.).
  • Requiring tracking on the server-side, where client-centric store persistence is unnecessary.
  • Granular control over each stage of a transaction’s lifecycle is required for custom workflows.

Why Use solanaFetcher?

Using solanaFetcher provides fast-block monitoring and signature status checking at the RPC node level, handling network lags and transaction signature swaps natively.

FeatureSolana RPC (manual polling)solanaFetcher (Pulsar)
Handles RPC Lags❌ No. If called immediately after submission, the RPC node might not have indexed the transaction yet, causing errors.Yes. Built-in retry mechanism to wait for the transaction to appear on-chain, mitigating RPC delays.
Full Lifecycle Support🤷‍♂️ Limited. You must manually implement logic for different states (sent, confirmed, failed).Yes. Provides callbacks for each stage: initialization, details fetched, mined, replaced, failed, etc.
Fetches Full Tx Details❌ No. Requires additional RPC calls to get full transaction info after confirmation.Yes. Calls for getTransaction internally, providing parsed transaction details to callbacks.
Abstraction LevelLow. You must manage the tracking states and polling manually.High. Encapsulates the entire process into a single, convenient async function, simplifying implementation.

In essence, solanaFetcher is a reliable tracking pipeline wrapper around Solana RPC functions, resolving common edge cases and ensuring robust signature status monitoring.


Trackers Overview

1. Solana Tracker

This is the primary tracker for monitoring standard transactions on Solana, identified via a transaction signature. It is designed to be used with initializePollingTracker from @tuwaio/pulsar-core.

How It Works

solanaFetcher initially attempts to fetch the transaction signature status. If the transaction is not found (due to RPC indexing lag), it retries. Once resolved, it continues to poll until the transaction is finalized. It also fetches full transaction details once they become available.

Example Usage

import { initializePollingTracker } from '@tuwaio/pulsar-core'; import { solanaFetcher } from '@tuwaio/pulsar-solana'; import { OrbitAdapter } from '@tuwaio/orbit-core'; async function trackMySolanaTransaction(txSignature: string, rpcUrl: string, chainId: string) { await initializePollingTracker({ tx: { txKey: txSignature, rpcUrl: rpcUrl, chainId: chainId, // e.g., 'solana:mainnet' or 'solana:devnet' adapter: OrbitAdapter.SOLANA, localTimestamp: Math.floor(Date.now() / 1000), pending: true, // Crucial: must be true to start polling loop }, fetcher: solanaFetcher, onIntervalTick: (response) => { console.log('Transaction status update:', response); // response includes slot, confirmations, confirmationStatus, etc. }, onSuccess: (response) => { console.log('Transaction finalized!', response); }, onFailure: (response) => { console.error('Tracking failed or transaction error:', response?.err); }, }); }

Helper Functions

signAndSendSolanaTx

This utility function simplifies the process of creating, signing, and broadcasting a Solana transaction to the network. It fetches the latest blockhash, creates a versioned transaction (v0), signs it with the provided signer, and sends it.

Example Usage

import type { Instruction, SolanaClient, TransactionSendingSigner } from 'gill'; import { signAndSendSolanaTx } from '@tuwaio/pulsar-solana'; async function sendTransaction( client: SolanaClient, signer: TransactionSendingSigner, instruction: Instruction | Instruction[], ) { try { const signature = await signAndSendSolanaTx({ client, signer, instruction, }); console.log('Transaction sent with signature:', signature); return signature; } catch (error) { console.error('Failed to send transaction:', error); } }

checkSolanaChain

This function verifies if the user is connected to the correct Solana network. It compares the required chain identifier with the current one and throws a SolanaChainMismatchError if they don’t match.

Example Usage

import { checkSolanaChain } from '@tuwaio/pulsar-solana'; async function ensureCorrectNetwork(requiredChain: string, currentChain: string) { try { checkSolanaChain(requiredChain, currentChain); console.log('Network is correct, proceeding...'); } catch (error) { console.error('Network mismatch:', error.message); } }
Last updated on