@somnia-chain/markets-sdk / chains / getSomniaChain
Function: getSomniaChain()
getSomniaChain(
chainId):Chain|null
Defined in: packages/sdk/src/chains/index.ts:107
Resolve a chain id to its definition, or null when it isn't a Somnia network
we ship. The chainId a deployment manifest carries is a plain number, so
this is the bridge from "the env told me 50312" to a viem Chain.
ts
import { getSomniaChain, defineChain } from "@somnia-chain/markets-sdk/chains";
const chain =
getSomniaChain(deployment.chainId) ??
defineChain({
id: deployment.chainId,
name: "Somnia",
nativeCurrency: { name: "STT", symbol: "STT", decimals: 18 },
rpcUrls: { default: { http: [rpcUrl] } },
});
Parameters
chainId
number
Chain id to look up (e.g. 50312).
Returns
Chain | null
The matching viem Chain, or null if it isn't one of ours.