Documentation Index
Fetch the complete documentation index at: https://mintlify.com/1inch/cross-chain-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The NetworkEnum enum provides type-safe chain ID constants for all supported networks in the 1inch Cross-Chain SDK.
Enum Definition
enum NetworkEnum {
ETHEREUM = 1,
POLYGON = 137,
ZKSYNC = 324,
BINANCE = 56,
ARBITRUM = 42161,
AVALANCHE = 43114,
OPTIMISM = 10,
FANTOM = 250,
GNOSIS = 100,
COINBASE = 8453,
LINEA = 59144,
SONIC = 146,
UNICHAIN = 130,
SOLANA = 501
}
Values
Gnosis Chain (formerly xDai)
Type Definitions
// Array of all supported chains
const SupportedChains: readonly NetworkEnum[]
// Type for supported chains
type SupportedChain = /* union of all supported chains */
// Type for EVM chains only (excludes Solana)
type EvmChain = Exclude<SupportedChain, NetworkEnum.SOLANA>
// Type for Solana
type SolanaChain = NetworkEnum.SOLANA
Helper Functions
isSupportedChain
Checks if a chain ID is supported.
function isSupportedChain(chain: unknown): chain is SupportedChain
Example:
import { isSupportedChain, NetworkEnum } from '@1inch/cross-chain-sdk'
console.log(isSupportedChain(NetworkEnum.ETHEREUM)) // true
console.log(isSupportedChain(1)) // true
console.log(isSupportedChain(999)) // false
isEvm
Checks if a chain is an EVM-compatible chain.
function isEvm(chain: SupportedChain): chain is EvmChain
Example:
import { isEvm, NetworkEnum } from '@1inch/cross-chain-sdk'
console.log(isEvm(NetworkEnum.ETHEREUM)) // true
console.log(isEvm(NetworkEnum.POLYGON)) // true
console.log(isEvm(NetworkEnum.SOLANA)) // false
isSolana
Checks if a chain is Solana.
function isSolana(chain: SupportedChain): chain is SolanaChain
Example:
import { isSolana, NetworkEnum } from '@1inch/cross-chain-sdk'
console.log(isSolana(NetworkEnum.SOLANA)) // true
console.log(isSolana(NetworkEnum.ETHEREUM)) // false
Usage Examples
In Quote Requests
import { SDK, NetworkEnum } from '@1inch/cross-chain-sdk'
const sdk = new SDK({ /* config */ })
const quote = await sdk.getQuote({
srcChainId: NetworkEnum.ETHEREUM,
dstChainId: NetworkEnum.POLYGON,
srcTokenAddress: '0x...',
dstTokenAddress: '0x...',
amount: '1000000',
walletAddress: '0x...',
enableEstimate: true
})
Type-Safe Chain Handling
import { NetworkEnum, isEvm, isSolana } from '@1inch/cross-chain-sdk'
function getChainName(chainId: NetworkEnum): string {
switch (chainId) {
case NetworkEnum.ETHEREUM:
return 'Ethereum'
case NetworkEnum.POLYGON:
return 'Polygon'
case NetworkEnum.BINANCE:
return 'BNB Chain'
case NetworkEnum.ARBITRUM:
return 'Arbitrum'
case NetworkEnum.OPTIMISM:
return 'Optimism'
case NetworkEnum.AVALANCHE:
return 'Avalanche'
case NetworkEnum.GNOSIS:
return 'Gnosis'
case NetworkEnum.COINBASE:
return 'Base'
case NetworkEnum.ZKSYNC:
return 'zkSync Era'
case NetworkEnum.LINEA:
return 'Linea'
case NetworkEnum.SONIC:
return 'Sonic'
case NetworkEnum.UNICHAIN:
return 'Unichain'
case NetworkEnum.SOLANA:
return 'Solana'
default:
return 'Unknown'
}
}
console.log(getChainName(NetworkEnum.ETHEREUM)) // 'Ethereum'
Chain-Specific Logic
function handleOrder(srcChainId: NetworkEnum, dstChainId: NetworkEnum) {
if (isEvm(srcChainId) && isEvm(dstChainId)) {
console.log('EVM to EVM swap')
// Use EVM-specific logic
} else if (isSolana(srcChainId) && isEvm(dstChainId)) {
console.log('Solana to EVM swap')
// Use Solana-specific logic
} else if (isEvm(srcChainId) && isSolana(dstChainId)) {
console.log('EVM to Solana swap')
// Use EVM to Solana logic
}
}
Iterating Supported Chains
import { SupportedChains } from '@1inch/cross-chain-sdk'
console.log('Supported chains:')
SupportedChains.forEach(chainId => {
console.log(` ${chainId}: ${getChainName(chainId)}`)
})
Validation
function validateCrossChainSwap(
srcChainId: number,
dstChainId: number
): void {
if (!isSupportedChain(srcChainId)) {
throw new Error(`Source chain ${srcChainId} is not supported`)
}
if (!isSupportedChain(dstChainId)) {
throw new Error(`Destination chain ${dstChainId} is not supported`)
}
if (srcChainId === dstChainId) {
throw new Error('Source and destination chains must be different')
}
console.log('✓ Valid cross-chain swap configuration')
}
validateCrossChainSwap(NetworkEnum.ETHEREUM, NetworkEnum.POLYGON)
Notes
Not all NetworkEnum values are actively supported for cross-chain swaps. Use the isSupportedChain() helper to verify chain support, or refer to the Supported Chains page.
Chain IDs match the official chain IDs from chainlist.org, except Solana which uses a custom ID of 501.
Use NetworkEnum constants instead of raw numbers for type safety and better code readability.
The SDK does not support same-chain swaps. Source and destination chains must be different.