Multi-Network
Testnet Ready
Mainnet Secure

Network Support

Seamless Bitcoin Network Integration

Build with confidence across Bitcoin networks. Full support for mainnet and testnet with automatic network detection and switching.

Mainnet
Production ready
Testnet
Development
Regtest
Local testing
Auto-Switch
Smart detection

Features

Multi-Network Support

Full support for Bitcoin mainnet, testnet, and regtest networks with seamless switching.

Network Safety

Built-in safeguards to prevent accidental mainnet transactions during testing.

Auto Detection

Automatic network detection from connected wallets and data providers.

Custom Networks

Support for custom network configurations and local development environments.

Network Configuration

Basic Setup

import { LaserEyesClient, createConfig, MAINNET, TESTNET } from '@omnisat/lasereyes-core'

// Mainnet configuration
const mainnetConfig = createConfig({
  network: MAINNET,
  dataSources: {
    mempool: { priority: 1 },
    maestro: { priority: 2 }
  }
})

// Testnet configuration
const testnetConfig = createConfig({
  network: TESTNET,
  dataSources: {
    mempool: {
      url: 'https://mempool.space/testnet/api',
      priority: 1
    }
  }
})

Network Detection

Auto Detection

import { useLaserEyes } from '@omnisat/lasereyes-react'

function NetworkStatus() {
  const { network, switchNetwork } = useLaserEyes()
  
  return (
    <div>
      <div>Current Network: {network}</div>
      <button onClick={() => switchNetwork(TESTNET)}>
        Switch to Testnet
      </button>
    </div>
  )
}

Advanced Examples

Custom Network Configuration

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

// Define custom network
const CUSTOM_NETWORK: NetworkType = {
  name: 'custom',
  networkId: 'bitcoin-custom',
  bech32: 'bc',
  pubKeyHash: 0x00,
  scriptHash: 0x05
}

// Create configuration
const config = createConfig({
  network: CUSTOM_NETWORK,
  dataSources: {
    custom: {
      url: 'https://your-bitcoin-node.com',
      priority: 1
    }
  }
})

Network Event Handling

import { useLaserEyes } from '@omnisat/lasereyes-react'
import { useEffect } from 'react'

function NetworkMonitor() {
  const { network, client } = useLaserEyes()

  useEffect(() => {
    const unsubscribe = client.on('networkChange', (newNetwork) => {
      console.log('Network changed:', newNetwork)
      // Update your app's state accordingly
    })

    return () => unsubscribe()
  }, [client])

  return <div>Current Network: {network}</div>
}

Best Practices

Network Validation

Always validate network compatibility before executing transactions to prevent errors.

Environment Separation

Use different configurations for development, staging, and production environments.

Error Handling

Implement proper error handling for network-related operations and switches.

Testing Strategy

Test your application thoroughly on testnet before deploying to mainnet.