Skip to main content

MetalayerClient.init(config)

Create an instance of the Metalayer SDK client with your configuration.

MetalayerConfig

PropertyTypeDescriptionDefaultRequired
apiKeystringYour application’s API key for the Metalayer API-
environment'production' | 'staging' | 'development'The environment to use. 'production' for mainnets, 'staging' for testnets'production'
defaultOptionsMetalayerOptionsDefault options for the Metalayer client{ quotePreference: 'bestReturn' }
customApiUrlstringOverride the default API URL for the environmentundefined
Environment Selection: API keys are only issued for production and staging environments. The development environment is not recommended for use and does not have API key support. Use staging for testnets and production for mainnets.
const client = MetalayerClient.init({
  apiKey: 'your-api-key',
  environment: 'production',
  defaultOptions: {
    quotePreference: 'fastest',
    chainIds: [1, 33139, 42161], // Filter for Ethereum Mainnet, ApeChain, Arbitrum One
  },
});

MetalayerOptions

PropertyTypeDescriptionDefaultRequired
quotePreference'bestReturn' | 'fastest'Quote optimization preference for routing'bestReturn'
chainIdsnumber[]Default chain IDs for internal filtering in getSupportedChains(), getTokens(), and getOrders() methods. Can be overridden by method parametersundefined

client.getSupportedChains(params?)

Get supported blockchain networks.

Parameters

PropertyTypeDescriptionDefaultRequired
chainIdsnumber[]List of chain IDs to filter. Defaults to all chains or SDK config chainIds if not provided. The response will return chain metadata for all chains in this listSDK config chainIds or all chains
// Get all supported chains
const { chains } = await client.getSupportedChains();

// Get specific chains only
const { chains } = await client.getSupportedChains({
  chainIds: [1, 33139, 42161] // Ethereum Mainnet, ApeChain, Arbitrum One
});

Response

PropertyTypeDescription
chainsChain[]List of blockchain networks supported for cross-chain routing

client.getTokens(params?)

Get token information by chain.

Parameters

PropertyTypeDescriptionDefaultRequired
chainIdsnumber[]Filters tokens by chain ID presence in this list. Defaults to all chains or SDK config chainIds if not providedSDK config chainIds or all chains
// Get tokens for all supported chains
const { tokensByChain } = await client.getTokens();

// Get tokens for specific chains
const { tokensByChain } = await client.getTokens({
  chainIds: [1, 33139, 42161] // Ethereum Mainnet, ApeChain, Arbitrum One
});

Response

PropertyTypeDescription
tokensByChainRecord<number, TokenList>Mapping of chain ID to available tokens for that chain

client.quote(params)

Get quotes for cross-chain bridging.

Parameters

PropertyTypeDescriptionDefaultRequired
sourceChainIdnumberSource chain ID-
sourceTokenAddressstringSource token address-
destinationChainIdnumberDestination chain ID-
destinationTokenAddressstringDestination token address-
amountBigIntAmount to swap-
senderAddressstringSender wallet address-
receiverAddressstringReceiver wallet address. Required when bridging between different architectures (e.g., Ethereum → Solana)senderAddress❌ (✅ if cross-architecture)
quotePreference'bestReturn' | 'fastest'Quote optimization preference'bestReturn'
const response = await client.quote({
  sourceChainId: 1,
  sourceTokenAddress: '0x0000000000000000000000000000000000000000',
  destinationChainId: 33139,
  destinationTokenAddress: '0x0000000000000000000000000000000000000000',
  amount: BigInt('1000000000000000000'),
  senderAddress: '0xYourAddress',
});

Response

PropertyTypeDescription
sourceChainChainIdentifierSource chain information
destinationChainChainIdentifierDestination chain information
sourceTokenTokenSource token information
destinationTokenTokenDestination token information
quotesQuote[]Array of quotes sorted by quotePreference

client.getOrder(params)

Get order details for a specific transaction.

Parameters

PropertyTypeDescriptionDefaultRequired
sourceTransactionHashstringTransaction hash-
sourceChainIdnumberSource chain ID-
const response = await client.getOrder({
  sourceTransactionHash: '0xTxHash',
  sourceChainId: 1,
});

Response

PropertyTypeDescription
orderOrderThe order matching the request identifier
import { OrderStatus } from '@metalayer/sdk';

const { order } = await client.getOrder({
  sourceTransactionHash: '0xTxHash',
  sourceChainId: 1,
});

// Check specific status
if (order.status === OrderStatus.FULFILLED) {
  console.log('Bridge transaction completed!');
}

client.getOrders(params)

Returns a list of orders for a wallet address.

Parameters

PropertyTypeDescriptionDefaultRequired
addressstringWallet address to get orders for-
chainIdsnumber[]List of chain IDs to filter the orders from. Defaults to all chains or SDK config chainIds if not providedSDK config chainIds or all chains
// Get all orders for a wallet
const response = await client.getOrders({
  address: '0xWalletAddress',
});

// Get orders filtered by specific chains
const response = await client.getOrders({
  address: '0xWalletAddress',
  chainIds: [1, 33139, 42161], // Ethereum Mainnet, Ape Chain, Arbitrum One
});

Response

PropertyTypeDescription
ordersOrder[]List of orders for the requested address
tokensRecord<string, Token>Token metadata indexed by “chainId_tokenAddress” keys