Skip to main content
The Avail Nexus SDK exports various constants for events, steps, chain IDs, and metadata. This reference covers all exported constant values.

Events

Event name constants used in onEvent callbacks.

NEXUS_EVENTS

Use these constants to identify events in your callbacks:
import { NEXUS_EVENTS } from '@avail-project/nexus-core';

export const NEXUS_EVENTS = {
  STEP_COMPLETE: 'STEP_COMPLETE',
  SWAP_STEP_COMPLETE: 'SWAP_STEP_COMPLETE',
  STEPS_LIST: 'STEPS_LIST',
} as const;
EventDescriptionWhen Emitted
STEPS_LISTEmitted once at operation start with all expected stepsBeginning of bridge/swap operations
STEP_COMPLETEEmitted when a bridge step completesAfter each bridge step finishes
SWAP_STEP_COMPLETEEmitted when a swap step completesAfter each swap step finishes
Example usage:
await sdk.bridge(params, {
  onEvent: (event) => {
    switch (event.name) {
      case NEXUS_EVENTS.STEPS_LIST:
        console.log('All steps:', event.args);
        break;
      case NEXUS_EVENTS.STEP_COMPLETE:
        console.log('Step done:', event.args);
        break;
    }
  },
});

Bridge Steps

Constants for tracking bridge operation progress.

BRIDGE_STEPS

import { BRIDGE_STEPS } from '@avail-project/nexus-core';
Step TypeType IDDescription
INTENT_ACCEPTEDIAIntent created and accepted by solver
INTENT_HASH_SIGNEDIHSUser signed the intent hash
INTENT_SUBMITTEDISIntent submitted to the network
INTENT_FULFILLEDIFIntent fulfilled by solver
ALLOWANCE_APPROVAL_REQUESTAUA_{chainId}Waiting for user to approve token allowance
ALLOWANCE_APPROVAL_MINEDAAM_{chainId}Allowance approval transaction mined
ALLOWANCE_COMPLETEAADAll required allowances approved
INTENT_DEPOSIT_REQUESTID_{index}Deposit initiated on source chain
INTENT_DEPOSITS_CONFIRMEDUIDCAll deposits confirmed on source chains
INTENT_COLLECTIONIC_{index}Collecting funds from source chain
INTENT_COLLECTION_COMPLETEICCAll funds collected from sources
EXECUTE_APPROVAL_STEPAPToken approval for execution
EXECUTE_TRANSACTION_SENTTSExecute transaction sent to network
EXECUTE_TRANSACTION_CONFIRMEDCNExecute transaction confirmed

Bridge Step Data Structure

type BridgeStepType = {
  type: string;   // Step type name
  typeID: string; // Unique identifier
  data?: {
    chainID?: number;
    chainName?: string;
    amount?: string;
    explorerURL?: string;
    intentID?: number;
    txHash?: Hex;
  };
};
Example: Tracking bridge progress
import { NEXUS_EVENTS, BRIDGE_STEPS } from '@avail-project/nexus-core';

const completedSteps = new Set<string>();

await sdk.bridge(params, {
  onEvent: (event) => {
    if (event.name === NEXUS_EVENTS.STEP_COMPLETE) {
      completedSteps.add(event.args.typeID);
      
      if (event.args.type === 'INTENT_SUBMITTED') {
        console.log('View on explorer:', event.args.data?.explorerURL);
      }
    }
  },
});

Swap Steps

Constants for tracking swap operation progress.

SWAP_STEPS

import { SWAP_STEPS } from '@avail-project/nexus-core';
Step TypeType IDDescription
SWAP_STARTSWAP_STARTSwap operation started
DETERMINING_SWAPDETERMINING_SWAPCalculating optimal swap route
CREATE_PERMIT_EOA_TO_EPHEMERALCREATE_PERMIT_EOA_TO_EPHEMERAL_{chainId}_{symbol}Creating permit for ephemeral wallet
CREATE_PERMIT_FOR_SOURCE_SWAPCREATE_PERMIT_FOR_SOURCE_SWAP_{chainId}_{symbol}Creating permit for source swap
SOURCE_SWAP_BATCH_TXSOURCE_SWAP_BATCH_TXExecuting source chain swap batch
SOURCE_SWAP_HASHSOURCE_SWAP_HASH_{chainId}Source swap transaction hash available
BRIDGE_DEPOSITBRIDGE_DEPOSIT_{chainId}Bridge deposit for cross-chain swap
RFF_IDRFF_IDRequest for funds ID assigned
DESTINATION_SWAP_BATCH_TXDESTINATION_SWAP_BATCH_TXExecuting destination swap batch
DESTINATION_SWAP_HASHDESTINATION_SWAP_HASH_{chainId}Destination swap transaction hash
SWAP_COMPLETESWAP_COMPLETESwap completed successfully
SWAP_SKIPPEDSWAP_SKIPPEDSwap skipped (sufficient balance exists)

Swap Step Data Structure

type SwapStepType = {
  type: string;
  typeID: string;
  completed: boolean;
  chain?: { id: number; name: string };
  symbol?: string;
  explorerURL?: string;
  data?: any; // Varies by step
};
Example: Tracking swap progress
import { NEXUS_EVENTS, SWAP_STEPS } from '@avail-project/nexus-core';

await sdk.swapWithExactIn(params, {
  onEvent: (event) => {
    if (event.name === NEXUS_EVENTS.SWAP_STEP_COMPLETE) {
      if (event.args.type === 'SWAP_SKIPPED') {
        console.log('Swap skipped - using existing balance');
      }
      if (event.args.type === 'SOURCE_SWAP_HASH') {
        console.log('Source swap:', event.args.explorerURL);
      }
    }
  },
});

Chain IDs

Constants for supported blockchain networks.

MAINNET_CHAIN_IDS

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

export const MAINNET_CHAIN_IDS = {
  ETHEREUM: 1,
  BASE: 8453,
  ARBITRUM: 42161,
  OPTIMISM: 10,
  POLYGON: 137,
  AVALANCHE: 43114,
  SCROLL: 534352,
  KAIA: 8217,
  CITREA: 4114,
  BNB: 56,
  HYPEREVM: 999,
  MEGAETH: 4326,
  MONAD: 143,
} as const;

TESTNET_CHAIN_IDS

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

export const TESTNET_CHAIN_IDS = {
  SEPOLIA: 11155111,
  BASE_SEPOLIA: 84532,
  ARBITRUM_SEPOLIA: 421614,
  CITREA_TESTNET: 5115,
  OPTIMISM_SEPOLIA: 11155420,
  POLYGON_AMOY: 80002,
  MONAD_TESTNET: 10143,
} as const;

SUPPORTED_CHAINS

Combination of all mainnet and testnet chains:
import { SUPPORTED_CHAINS } from '@avail-project/nexus-core';

// Use in your code
const chainId = SUPPORTED_CHAINS.ETHEREUM; // 1
const baseChain = SUPPORTED_CHAINS.BASE; // 8453

Chain Metadata

Detailed chain information including RPC URLs and block explorers.

CHAIN_METADATA

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

const ethMetadata = CHAIN_METADATA[1];
Structure:
type ChainMetadata = {
  id: number;
  name: string;
  shortName: string;
  logo: string;
  nativeCurrency: {
    name: string;
    symbol: string;
    decimals: number;
  };
  rpcUrls: string[];
  blockExplorerUrls: string[];
};
Example:
const polygon = CHAIN_METADATA[137];
console.log(polygon.name); // "Polygon"
console.log(polygon.nativeCurrency.symbol); // "MATIC"
console.log(polygon.rpcUrls[0]); // "https://polygon-rpc.com"
console.log(polygon.blockExplorerUrls[0]); // "https://polygonscan.com"

Token Metadata

Token information including symbols, names, and decimals.

TOKEN_METADATA

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

const usdc = TOKEN_METADATA.USDC;
Structure:
type TokenMetadata = {
  symbol: string;
  name: string;
  decimals: number;
  icon: string;
  coingeckoId: string;
  isNative?: boolean;
};
Available tokens:
// Mainnet tokens
TOKEN_METADATA.ETH
TOKEN_METADATA.USDC
TOKEN_METADATA.USDT

// Access metadata
const usdc = TOKEN_METADATA.USDC;
console.log(usdc.decimals); // 6
console.log(usdc.name); // "USD Coin"

Token Contract Addresses

Token addresses across all supported chains.

TOKEN_CONTRACT_ADDRESSES

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

// Get USDC address on Ethereum
const usdcOnEth = TOKEN_CONTRACT_ADDRESSES.USDC[SUPPORTED_CHAINS.ETHEREUM];
// "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"

// Get USDT on Polygon
const usdtOnPolygon = TOKEN_CONTRACT_ADDRESSES.USDT[SUPPORTED_CHAINS.POLYGON];
// "0xc2132d05d31c914a87c6611c10748aeb04b58e8f"
Structure:
export const TOKEN_CONTRACT_ADDRESSES = {
  USDC: {
    [chainId: number]: '0x...'
  },
  USDT: {
    [chainId: number]: '0x...'
  },
  USDM: {
    [chainId: number]: '0x...'
  },
} as const;
See Supported Tokens for complete address list.

Error Codes

All error code constants.

ERROR_CODES

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

// Use in error handling
try {
  await sdk.bridge(params);
} catch (error) {
  if (error.code === ERROR_CODES.INSUFFICIENT_BALANCE) {
    // Handle insufficient balance
  }
}
See Error Codes for complete reference.

Other Constants

Intent Expiry

Intent expiration time (used internally):
const INTENT_EXPIRY = 15 * 60 * 1000; // 15 minutes in milliseconds

Zero Address

Constants for native token representation:
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
const ZERO_ADDRESS_BYTES_32 = '0x0000000000000000000000000000000000000000000000000000000000000000';
Native tokens (ETH, MATIC, etc.) use the zero address in swap operations.

Complete Import Example

import {
  // Events
  NEXUS_EVENTS,
  
  // Steps
  BRIDGE_STEPS,
  SWAP_STEPS,
  
  // Chain IDs
  SUPPORTED_CHAINS,
  MAINNET_CHAIN_IDS,
  TESTNET_CHAIN_IDS,
  
  // Metadata
  CHAIN_METADATA,
  TOKEN_METADATA,
  TOKEN_CONTRACT_ADDRESSES,
  
  // Errors
  ERROR_CODES,
  
  // Types
  type BridgeStepType,
  type SwapStepType,
  type ChainMetadata,
  type TokenMetadata,
} from '@avail-project/nexus-core';

// Use constants in your application
const sdk = new NexusSDK({ network: 'mainnet' });

await sdk.bridge(
  {
    token: 'USDC',
    amount: 100_000_000n,
    toChainId: SUPPORTED_CHAINS.POLYGON, // Use constant
  },
  {
    onEvent: (event) => {
      if (event.name === NEXUS_EVENTS.STEP_COMPLETE) {
        console.log('Step completed:', event.args.type);
      }
    },
  }
);
All constants are typed with TypeScript’s as const for maximum type safety and autocomplete support.

Build docs developers (and LLMs) love