Skip to main content

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:


_10
import * as fcl from "@onflow/fcl-react-native"
_10
_10
fcl.getChainId(opts)

Or import directly the specific function:


_10
import { getChainId } from "@onflow/fcl-react-native"
_10
_10
getChainId(opts)

Usage


_10
// Get chain ID using configured access node
_10
import * as fcl from "@onflow/fcl"
_10
_10
const chainId = await fcl.getChainId()
_10
console.log("Connected to:", chainId) // "testnet" or "mainnet"

Parameters

opts (optional)

  • Type:

_10
export 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")


Rate this page