getChainId
Gets the chain ID if its set, otherwise gets the chain ID from the access node
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl-react-native"_10_10fcl.getChainId(opts)
Or import directly the specific function:
_10import { getChainId } from "@onflow/fcl-react-native"_10_10getChainId(opts)
Usage
_10// Get chain ID using configured access node_10import * as fcl from "@onflow/fcl"_10_10const chainId = await fcl.getChainId()_10console.log("Connected to:", chainId) // "testnet" or "mainnet"
Parameters
opts
(optional)
- Type:
_10export interface GetChainIdOptions {_10 node?: unknown_10 enableRequestLogging?: boolean_10 [key: string]: any_10}
- Description: Optional configuration parameters
Returns
Promise<string>
Promise that resolves to the chain ID string (e.g., "mainnet", "testnet", "local")