Skip to main content

ping

A builder function that creates a ping interaction to test connectivity to the Flow Access Node.

The ping interaction is a simple way to test if the Flow Access Node is reachable and responding. This is useful for health checks, connectivity testing, and debugging network issues.

Import

You can import the entire package and access the function:


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

Or import directly the specific function:


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

Usage


_22
import * as fcl from "@onflow/fcl";
_22
_22
// Simple ping to test connectivity
_22
try {
_22
const response = await fcl.send([fcl.ping()]);
_22
console.log("Access Node is reachable");
_22
} catch (error) {
_22
console.error("Access Node is not reachable:", error);
_22
}
_22
_22
// Use ping for health checks
_22
const healthCheck = async () => {
_22
try {
_22
await fcl.send([fcl.ping()]);
_22
return { status: "healthy", timestamp: new Date().toISOString() };
_22
} catch (error) {
_22
return { status: "unhealthy", error: error.message, timestamp: new Date().toISOString() };
_22
}
_22
};
_22
_22
const health = await healthCheck();
_22
console.log("Health status:", health);

Returns

InteractionBuilderFn


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


Rate this page