Skip to main content
The Data Module is your central hub for fetching, processing, and managing on-chain and off-chain data related to Solana assets. It provides seamless integration with multiple data sources including Helius, Birdeye, and CoinGecko.

Core Functionalities

Token Data

Fetch token metadata, balances, prices, and historical price data from multiple sources

NFT & Portfolio Assets

Retrieve user portfolio assets including NFTs and compressed NFTs (cNFTs)

Market Information

Access comprehensive market data from CoinGecko including OHLC and market details

Transaction History

Fetch and process user swap transaction history with enriched metadata

Installation & Setup

1

Environment Variables

Configure your API keys in .env.local:
2

Import Module

Import the hooks and services you need:
3

Start Fetching

Use the hooks in your components to fetch data

Module Architecture

Core Services

tokenService.ts - Core token data operations

Essential Hooks

useFetchTokens()

Fetches all fungible tokens in a user’s wallet with portfolio data.
Returns:
  • tokens - Array of user’s tokens
  • loading - Loading state
  • error - Error message if any
  • refetch - Function to refresh data

useTokenDetails()

Comprehensive token information for detail views.
Parameters:
  • tokenAddress - Token mint address
  • visible - Whether to actively fetch data
Returns:
  • priceHistory - Historical price data
  • metadata - Token metadata
  • tokenOverview - Overview information
  • loading - Loading states
  • selectedTimeframe - Current timeframe
  • handleTimeframeChange - Timeframe selector

useCoingecko()

Access CoinGecko market data with caching.

useTokenSearch()

Debounced token search with pagination.

Quick Start Example

Utility Functions

object
object
object

Data Sources Integration

Helius

Primary Use: RPC calls, transaction history, asset fetching
  • Enhanced Solana RPC
  • Transaction parsing
  • Asset metadata

Birdeye

Primary Use: Token prices, security analysis, market data
  • Real-time prices
  • Security scoring
  • Trade data
  • Price history

CoinGecko

Primary Use: Market information, coin listings
  • Coin directories
  • Market cap data
  • OHLC data
  • Global statistics

Advanced Usage Patterns

Custom Data Fetching

Batch Data Operations

Real-time Price Updates

Error Handling

API Rate Limits: Be mindful of rate limits when making frequent requests. The module includes retry logic but respect provider limits.

Performance Optimization

Caching: The module implements intelligent caching for CoinGecko data and token metadata to reduce API calls.

Integration with Other Modules

With Wallet Providers

With Swap Module

Troubleshooting

object

API Reference

For detailed API documentation, see:
The Data Module serves as the foundation for all blockchain data needs in your Solana application, providing reliable, cached, and efficiently formatted data from multiple sources.