MetalayerClient.init(config)
Create an instance of the Metalayer SDK client with your configuration.
MetalayerConfig
Property | Type | Description | Default | Required |
---|---|---|---|---|
apiKey | string | Your application’s API key for the Metalayer API | - | ✅ |
environment | 'production' | 'staging' | The environment to use. 'production' for mainnets, 'staging' for testnets | 'production' | ✅ |
defaultOptions | MetalayerOptions | Default options for the Metalayer client | { quotePreference: 'bestReturn' } | ❌ |
customApiUrl | string | Override the default API URL for the environment | undefined | ❌ |
MetalayerOptions
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 | ❌ |
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 | ❌ |
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' | ❌ |
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 | - | ✅ |
Response
Property | Type | Description |
---|---|---|
order | Order | The order matching the request identifier |
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 | ❌ |
Response
Property | Type | Description |
---|---|---|
orders | Order[] | List of orders for the requested address |
tokens | Record<string, Token> | Token metadata indexed by “chainId_tokenAddress” keys |