Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/availproject/nexus-sdk/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Nexus SDK provides comprehensive chain metadata and utilities to query supported networks and tokens.

getSupportedChains

Get all supported chains and tokens for a specific network environment.
import { getSupportedChains } from '@avail-project/nexus-core';

// Get mainnet chains
const mainnet = getSupportedChains('mainnet');

// Get testnet chains
const testnet = getSupportedChains('testnet');

// Via SDK instance
const chains = sdk.utils.getSupportedChains();

Parameters

env
'mainnet' | 'testnet'
The network environment. Defaults to SDK’s configured network.

Returns

result
SupportedChainsAndTokensResult
chains
Chain[]
Array of supported chains with metadata
tokens
TokenInfo[]
Array of supported tokens across chains

Examples

import { getSupportedChains } from '@avail-project/nexus-core';

const { chains, tokens } = getSupportedChains('mainnet');

chains.forEach(chain => {
  console.log(`${chain.name} (ID: ${chain.id})`);
  console.log(`Native: ${chain.nativeCurrency.symbol}`);
  console.log(`Explorer: ${chain.blockExplorers.default.url}`);
});

CHAIN_METADATA

Static metadata for all supported chains indexed by chain ID.
import { CHAIN_METADATA } from '@avail-project/nexus-core';

const ethereum = CHAIN_METADATA[1];
console.log(ethereum.name); // "Ethereum"
console.log(ethereum.nativeCurrency.symbol); // "ETH"

const polygon = CHAIN_METADATA[137];
console.log(polygon.name); // "Polygon"
console.log(polygon.shortName); // "matic"

Structure

ChainMetadata
object
id
number
Chain ID (e.g., 1 for Ethereum, 137 for Polygon)
name
string
Full chain name (e.g., “Ethereum”, “Arbitrum One”)
shortName
string
Short identifier (e.g., “eth”, “arb1”, “matic”)
Chain logo URL
nativeCurrency
object
name
string
Native currency name (e.g., “Ether”)
symbol
string
Native currency symbol (e.g., “ETH”)
decimals
number
Decimals (usually 18)
rpcUrls
string[]
RPC endpoint URLs
blockExplorerUrls
string[]
Block explorer URLs

Examples

import { CHAIN_METADATA } from '@avail-project/nexus-core';

function getChainInfo(chainId: number) {
  const chain = CHAIN_METADATA[chainId];
  if (!chain) {
    throw new Error(`Chain ${chainId} not supported`);
  }
  return chain;
}

const base = getChainInfo(8453);
console.log(base.name); // "Base"
console.log(base.blockExplorerUrls[0]); // "https://basescan.org"

TOKEN_METADATA

Metadata for supported tokens across all chains.
import { TOKEN_METADATA } from '@avail-project/nexus-core';

const usdc = TOKEN_METADATA['USDC'];
console.log(usdc.name); // "USD Coin"
console.log(usdc.decimals); // 6
console.log(usdc.icon); // URL to USDC icon

Structure

TokenMetadata
object
symbol
string
Token symbol (e.g., “USDC”, “ETH”, “USDT”)
name
string
Full token name (e.g., “USD Coin”)
decimals
number
Decimal places (e.g., 6 for USDC, 18 for ETH)
icon
string
Token icon URL
coingeckoId
string
CoinGecko API identifier
isNative
boolean
Whether this is a native token (true for ETH)

Examples

import { TOKEN_METADATA } from '@avail-project/nexus-core';

function TokenInfo({ symbol }: { symbol: string }) {
  const token = TOKEN_METADATA[symbol];
  if (!token) return null;
  
  return (
    <div className="token-info">
      <img src={token.icon} alt={symbol} />
      <div>
        <div className="symbol">{token.symbol}</div>
        <div className="name">{token.name}</div>
      </div>
    </div>
  );
}

SUPPORTED_CHAINS

Constants for all supported chain IDs.
import { SUPPORTED_CHAINS } from '@avail-project/nexus-core';

console.log(SUPPORTED_CHAINS.ETHEREUM); // 1
console.log(SUPPORTED_CHAINS.BASE); // 8453
console.log(SUPPORTED_CHAINS.ARBITRUM); // 42161
console.log(SUPPORTED_CHAINS.POLYGON); // 137

Mainnet Chains

SUPPORTED_CHAINS
object
ETHEREUM
1
Ethereum Mainnet
BASE
8453
Base
ARBITRUM
42161
Arbitrum One
OPTIMISM
10
Optimism
POLYGON
137
Polygon PoS
AVALANCHE
43114
Avalanche C-Chain
SCROLL
534352
Scroll
KAIA
8217
Kaia Mainnet
CITREA
4114
Citrea Mainnet
BNB
56
BNB Smart Chain
HYPEREVM
999
Hyper EVM
MEGAETH
4326
MegaETH
MONAD
143
Monad

Testnet Chains

SUPPORTED_CHAINS
object
SEPOLIA
11155111
Sepolia
BASE_SEPOLIA
84532
Base Sepolia
ARBITRUM_SEPOLIA
421614
Arbitrum Sepolia
OPTIMISM_SEPOLIA
11155420
Optimism Sepolia
POLYGON_AMOY
80002
Polygon Amoy
MONAD_TESTNET
10143
Monad Testnet
CITREA_TESTNET
5115
Citrea Testnet

Examples

import { SUPPORTED_CHAINS } from '@avail-project/nexus-core';

// Use constants instead of magic numbers
await sdk.bridge({
  token: 'USDC',
  amount: 100_000_000n,
  toChainId: SUPPORTED_CHAINS.POLYGON,
});

// Check if chain is supported
function isSupportedChain(chainId: number): boolean {
  return Object.values(SUPPORTED_CHAINS).includes(chainId);
}

SDK Utils Instance

The SDK instance provides utility methods for chain queries.
import { NexusSDK } from '@avail-project/nexus-core';

const sdk = new NexusSDK({ network: 'mainnet' });
await sdk.initialize(window.ethereum);

// Get supported chains
const chains = sdk.utils.getSupportedChains();

// Check if chain is supported
const isSupported = sdk.utils.isSupportedChain(137);

// Check if token is supported
const isTokenSupported = sdk.utils.isSupportedToken('USDC');

// Get swap-supported chains
const swapChains = sdk.utils.getSwapSupportedChainsAndTokens();

Available Methods

sdk.utils
NexusUtils
getSupportedChains
(env?: Network) => SupportedChainsAndTokensResult
Get all supported chains and tokens
isSupportedChain
(chainId: number) => boolean
Check if a chain ID is supported
isSupportedToken
(token: string) => boolean
Check if a token symbol is supported
getSwapSupportedChainsAndTokens
() => SupportedChainsResult
Get chains and tokens that support swap operations
getCoinbaseRates
() => Promise<Record<string, string>>
Get current token prices from Coinbase

Examples

if (!sdk.utils.isSupportedChain(chainId)) {
  throw new Error(`Chain ${chainId} is not supported`);
}

if (!sdk.utils.isSupportedToken('CUSTOM')) {
  throw new Error('Token not supported');
}

Best Practices

Use constants for chain IDs

Always use SUPPORTED_CHAINS constants instead of hardcoding chain IDs for better maintainability.

Validate before operations

Use isSupportedChain() and isSupportedToken() to validate inputs before SDK operations.

Cache chain metadata

CHAIN_METADATA and TOKEN_METADATA are static - cache them in your app to avoid repeated lookups.

Display user-friendly names

Use chain.name from metadata instead of chain IDs when displaying to users.

Common Patterns

import { CHAIN_METADATA, SUPPORTED_CHAINS } from '@avail-project/nexus-core';

const MAINNET_CHAINS = [
  SUPPORTED_CHAINS.ETHEREUM,
  SUPPORTED_CHAINS.BASE,
  SUPPORTED_CHAINS.ARBITRUM,
  SUPPORTED_CHAINS.POLYGON,
];

function ChainDropdown({ 
  value, 
  onChange 
}: { 
  value: number;
  onChange: (chainId: number) => void;
}) {
  return (
    <select value={value} onChange={e => onChange(Number(e.target.value))}>
      {MAINNET_CHAINS.map(chainId => {
        const chain = CHAIN_METADATA[chainId];
        return (
          <option key={chainId} value={chainId}>
            {chain.name}
          </option>
        );
      })}
    </select>
  );
}