Utility Functions
The SDK provides utility functions for common operations:chainToViemChain(chain)
Convert a Metalayer Chain object to Viem chain format. Use the result as your wagmi chains list and pass the same viem Chain values into @metalayer/widget helpers such as createWidgetTransport, createWidgetClient, and createWidgetTransportsRecord (see Widget Components).
chainsToViemChains(chains)
Convert an array of Metalayer Chain objects to an array of Viem chains. Invalid or non-EVM chains are filtered out. The returned array is suitable for wagmi and for the widget transport helpers linked above.
collectChainHttpRpcUrls(chain)
Collects unique HTTP RPC URLs from a viem Chain produced by chainToViemChain, in Metalayer order: URLs under rpcUrls.default, then alternate slots rpc-0, rpc-1, … (sorted by index), which map to alternativeRpcs from the Metalayer chain. Used internally by createWidgetTransport in @metalayer/widget; you can use it directly when building custom viem fallback() stacks or other transports.