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
The network environment. Defaults to SDK’s configured network.
Returns
result
SupportedChainsAndTokensResult
Array of supported chains with metadata
Array of supported tokens across chains
Examples
Get All Chains
Filter by Swap Support
Build Chain Selector
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 } ` );
});
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
Chain ID (e.g., 1 for Ethereum, 137 for Polygon)
Full chain name (e.g., “Ethereum”, “Arbitrum One”)
Short identifier (e.g., “eth”, “arb1”, “matic”)
Native currency name (e.g., “Ether”)
Native currency symbol (e.g., “ETH”)
Examples
Get Chain Info
Display Chain Badge
Add Network to Wallet
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"
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
Token symbol (e.g., “USDC”, “ETH”, “USDT”)
Full token name (e.g., “USD Coin”)
Decimal places (e.g., 6 for USDC, 18 for ETH)
Whether this is a native token (true for ETH)
Examples
Display Token Info
Token Dropdown
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
Testnet Chains
Examples
Type-Safe Chain IDs
Chain Validation
import { SUPPORTED_CHAINS } from '@avail-project/nexus-core' ;
// Use constants instead of magic numbers
await sdk . bridge ({
token: 'USDC' ,
amount: 100_000_000 n ,
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
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
Chain Validation
Get Token Prices
Swap Chain Selector
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
Chain Dropdown Component
Explorer Link Generator
Network Switcher
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 >
);
}