Overview
The Chains API provides a list of all blockchain networks supported by OneBalance. This includes both mainnet and testnet chains, along with their metadata for proper identification and display.API Methods
getChains
Retrieve the complete list of supported blockchain chains.Parameters
This method takes no parameters.Returns
array
Array of all supported blockchain chains
Example
Example Response
Chain Configuration
OneBalance provides additional chain metadata through theCHAIN_CONFIG constant:
Utility Functions
The chains module provides several utility functions for working with chain data:getChainName
Get the human-readable name for a chain ID.getChainLogoUrl
Get the logo URL for a chain.getChainConfig
Get complete configuration for a chain.extractChainIdFromCAIP
Extract chain ID from CAIP chain identifier.extractChainIdFromAssetType
Extract chain ID from CAIP-19 asset type.Real-World Implementation
Supported Chains
OneBalance currently supports the following chains:Ethereum
Chain ID:
1The original smart contract platformOptimism
Chain ID:
10Ethereum Layer 2 for lower feesPolygon
Chain ID:
137Fast and low-cost EVM sidechainBase
Chain ID:
8453Coinbase’s Ethereum L2Arbitrum
Chain ID:
42161Popular Ethereum Layer 2Linea
Chain ID:
59144ConsenSys zkEVM L2Avalanche
Chain ID:
43114High-throughput blockchainUnichain
Chain ID:
130Uniswap’s dedicated chainSolana
Chain ID:
5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpHigh-performance blockchainFiltering Chains
Building Chain Selectors
Understanding CAIP-2
Chain identifiers use the CAIP-2 standard:- namespace: Blockchain type (e.g.,
eip155for EVM,solanafor Solana) - reference: Chain-specific identifier (chain ID for EVM chains)
Caching Strategy
Error Handling
Best Practices
Cache Results
Chains change very rarely - cache indefinitely or until app restart
Use Utility Functions
Use provided utilities like
getChainName() for consistent displayShow Chain Logos
Display chain logos for better visual identification
Filter Appropriately
Hide testnets in production, show them in development
Related APIs
- Assets API - Asset entities reference chain IDs
- Balances API - Individual balances include chain information
- Transactions API - Transactions include chain operations
Related Types
- Chain - Complete chain structure
- ChainMetadata - Chain identification
- ChainConfig - Display configuration