Skip to main content

getNetworkParameters

A builder function that returns the interaction to get network parameters.

Network parameters contain important configuration information about the Flow network, including the chain ID, which is essential for signing transactions correctly. This information is crucial for ensuring transactions are submitted to the correct network.

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.getNetworkParameters()

Or import directly the specific function:


_10
import { getNetworkParameters } from "@onflow/sdk"
_10
_10
getNetworkParameters()

Usage


_16
import * as fcl from "@onflow/fcl";
_16
_16
// Get network parameters to verify chain ID
_16
const params = await fcl.send([
_16
fcl.getNetworkParameters()
_16
]).then(fcl.decode);
_16
_16
console.log("Chain ID:", params.chainId);
_16
console.log("Network:", params.name);
_16
_16
// Use this to verify you're connected to the right network
_16
if (params.chainId === "flow-mainnet") {
_16
console.log("Connected to Flow Mainnet");
_16
} else if (params.chainId === "flow-testnet") {
_16
console.log("Connected to Flow Testnet");
_16
}

Returns

InteractionBuilderFn


_10
export type InteractionBuilderFn = (
_10
ix: Interaction
_10
) => Interaction | Promise<Interaction>


Rate this page