System

DataSource System

A powerful abstraction layer for interacting with Bitcoin data providers, offering flexibility, reliability, and seamless integration.

The DataSource system is a core component of LaserEyes that abstracts away the complexities of interacting with different Bitcoin data providers. This abstraction allows you to switch providers seamlessly, implement fallbacks, and maintain consistent data access across your application.

Key Features

Multiple Providers

Switch between different data providers without changing your application code.

Automatic Fallbacks

Use multiple data providers simultaneously for redundancy and reliability.

Custom Sources

Implement custom data sources for specialized needs with a simple interface.

Unified Interface

Handle provider-specific features through a consistent, type-safe API.

Supported Providers

Primary

Maestro

A comprehensive Bitcoin API with support for Ordinals, inscriptions, and more.

Learn more →
Primary

Sandshrew

Fast and reliable Bitcoin data indexing with excellent developer experience.

Learn more →
Secondary

Mempool.space

Open-source explorer and API for Bitcoin mempool and network data.

Learn more →
Secondary

Esplora

Blockstream's Bitcoin block explorer and HTTP API for basic operations.

Learn more →

Configuration

React Setup

import { LaserEyesProvider } from '@omnisat/lasereyes-react'
import { MAINNET } from '@omnisat/lasereyes-core'

function App() {
  return (
    <LaserEyesProvider
      config={{ 
        network: MAINNET,
        dataSources: {
          // Maestro configuration
          maestro: {
            apiKey: 'your-maestro-api-key',
          },
          // Sandshrew configuration
          sandshrew: {
            url: 'https://api.sandshrew.io',
            apiKey: 'your-sandshrew-api-key',
          },
          // Mempool.space configuration
          mempool: {
            url: 'https://mempool.space/api',
          },
          // Esplora configuration
          esplora: 'https://blockstream.info/api',
        }
      }}
    >
      <YourApp />
    </LaserEyesProvider>
  )
}

Provider Capabilities

FeatureMaestroSandshrewMempoolEsplora
Basic Bitcoin Operations
Ordinals & Inscriptions
BRC-20 Tokens
Runes

Custom Implementation

Custom DataSource

import { DataSource, NetworkType } from '@omnisat/lasereyes-core'

class CustomDataSource implements DataSource {
  constructor(private apiKey: string, private network: NetworkType) {}

  async getBalance(address: string): Promise<string> {
    const response = await fetch(
      `https://your-api.com/balance/${address}?apiKey=${this.apiKey}`
    )
    const data = await response.json()
    return data.balance
  }

  async getUtxos(address: string): Promise<UTXO[]> {
    const response = await fetch(
      `https://your-api.com/utxos/${address}?apiKey=${this.apiKey}`
    )
    const data = await response.json()
    return data.utxos
  }

  // Implement other required methods...
}

Best Practices

Multiple Providers

Configure multiple data providers for redundancy. If one provider fails, LaserEyes will automatically fall back to others.

API Keys

Register for your own API keys with data providers for production use. Development keys are rate-limited.

Error Handling

Implement proper error handling for blockchain operations. Network issues or provider outages can occur.

Caching

Cache frequently accessed data to reduce API calls and improve performance. Monitor your API usage.