Documentation Index
Fetch the complete documentation index at: https://docs.caldera.xyz/llms.txt
Use this file to discover all available pages before exploring further.
MetalayerClient.init(config)
Create an instance of the Metalayer SDK client with your configuration.
| Property | Type | Description | Default | Required |
|---|
apiKey | string | Your application’s API key for the Metalayer API | - | ✅ |
environment | 'mainnet' | 'testnet' | The environment to use. | 'mainnet' | ✅ |
defaultOptions | MetalayerOptions | Default options for the Metalayer client | { quotePreference: 'bestReturn' } | ❌ |
customApiUrl | string | Override the default API URL for the environment | undefined | ❌ |
const client = MetalayerClient.init({
apiKey: 'your-api-key',
environment: 'mainnet',
defaultOptions: {
quotePreference: 'fastest',
chainIds: [1, 33139, 42161], // Filter for Ethereum Mainnet, ApeChain, Arbitrum One
},
});
| Property | Type | Description | Default | Required |
|---|
quotePreference | 'bestReturn' | 'fastest' | Quote optimization preference for routing | 'bestReturn' | ❌ |
chainIds | number[] | Default chain IDs for internal filtering in getSupportedChains(), getTokens(), and getOrders() methods. Can be overridden by method parameters | undefined | ❌ |
client.getSupportedChains(params?)
Get supported blockchain networks.
Parameters
| Property | Type | Description | Default | Required |
|---|
chainIds | number[] | 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 list | SDK 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
| Property | Type | Description |
|---|
chains | Chain[] | List of blockchain networks supported for cross-chain routing |
client.getTokens(params?)
Get token information by chain.
Parameters
| Property | Type | Description | Default | Required |
|---|
chainIds | number[] | Filters tokens by chain ID presence in this list. Defaults to all chains or SDK config chainIds if not provided | SDK 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
| Property | Type | Description |
|---|
tokensByChain | Record<number, TokenList> | Mapping of chain ID to available tokens for that chain |
client.quote(params)
Get quotes for cross-chain bridging.
Parameters
| Property | Type | Description | Default | Required |
|---|
sourceChainId | number | Source chain ID | - | ✅ |
sourceTokenAddress | string | Source token address | - | ✅ |
destinationChainId | number | Destination chain ID | - | ✅ |
destinationTokenAddress | string | Destination token address | - | ✅ |
amount | BigInt | Amount to swap | - | ✅ |
senderAddress | string | Sender wallet address | - | ✅ |
receiverAddress | string | Receiver 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
| Property | Type | Description |
|---|
sourceChain | ChainIdentifier | Source chain information |
destinationChain | ChainIdentifier | Destination chain information |
sourceToken | Token | Source token information |
destinationToken | Token | Destination token information |
quotes | Quote[] | Array of quotes sorted by quotePreference |
client.getOrder(params)
Get order details for a specific transaction.
Parameters
| Property | Type | Description | Default | Required |
|---|
sourceTransactionHash | string | Transaction hash | - | ✅ |
sourceChainId | number | Source chain ID | - | ✅ |
const response = await client.getOrder({
sourceTransactionHash: '0xTxHash',
sourceChainId: 1,
});
Response
| Property | Type | Description |
|---|
order | Order | The 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
| Property | Type | Description | Default | Required |
|---|
address | string | Wallet address to get orders for | - | ✅ |
chainIds | number[] | List of chain IDs to filter the orders from. Defaults to all chains or SDK config chainIds if not provided | SDK 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
| Property | Type | Description |
|---|
orders | Order[] | List of orders for the requested address |
tokens | Record<string, Token> | Token metadata indexed by “chainId_tokenAddress” keys |