Skip to main content

createFcl

Creates a configured FCL (Flow Client Library) core instance. This function initializes FCL with the core functionality needed to interact with the Flow blockchain, providing a complete interface for blockchain operations.

The created FCL instance includes all core functionality for:

  • User authentication and wallet connections
  • Transaction submission and monitoring
  • Blockchain queries and event subscriptions
  • Configuration management
  • Discovery service integration
  • SDK method access

This function automatically configures the HTTP transport and creates all necessary services and utilities. The transport parameter is optional and defaults to HTTP transport.

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.createFcl(params)

Or import directly the specific function:


_10
import { createFcl } from "@onflow/fcl-core"
_10
_10
createFcl(params)

Usage


_30
// Basic FCL instance creation
_30
import { createFcl } from "@onflow/fcl-core"
_30
_30
const fcl = createFcl({
_30
accessNodeUrl: "https://rest-testnet.onflow.org",
_30
computeLimit: 1000,
_30
flowNetwork: "testnet"
_30
})
_30
_30
// Use the instance for authentication
_30
const user = await fcl.currentUser.authenticate()
_30
console.log("Authenticated user:", user.addr)
_30
_30
// Submit a transaction
_30
const txId = await fcl.mutate({
_30
cadence: `
_30
transaction {
_30
execute { log("Hello, Flow!") }
_30
}
_30
`
_30
})
_30
_30
// Query the blockchain
_30
const result = await fcl.query({
_30
cadence: `
_30
pub fun main(): Int {
_30
return 42
_30
}
_30
`
_30
})

Parameters

params

  • Type:

_10
WithOptionalProperties<FCLConfig, "transport">

  • Description: Configuration parameters for the FCL instance

Properties:

  • accessNodeUrl - URL of the Flow access node (e.g., "https://rest-testnet.onflow.org")
  • computeLimit - Default compute limit for transactions and queries
  • customResolver - Optional custom resolver for address replacement
  • customDecoders - Optional custom decoders for response parsing
  • contracts - Optional contract address mappings
  • platform - Platform identifier (e.g., "web", "mobile", "extension")
  • discoveryWallet - Optional discovery wallet endpoint
  • discoveryWalletMethod - Optional discovery wallet method
  • defaultComputeLimit - Optional default compute limit override
  • flowNetwork - Optional Flow network identifier
  • serviceOpenIdScopes - Optional OpenID scopes for services
  • walletconnectProjectId - Optional WalletConnect project ID
  • walletconnectDisableNotifications - Optional flag to disable WalletConnect notifications
  • storage - Storage provider for session persistence
  • discovery - Optional discovery configuration with execStrategy
  • transport - Optional transport layer (defaults to HTTP transport)

Returns

any

A fully configured FCL instance with all core methods and services including:

  • currentUser: User authentication and management service
  • config: Configuration management service
  • mutate: Transaction submission function
  • query: Blockchain query function
  • queryRaw: Raw blockchain query function
  • verifyUserSignatures: User signature verification
  • getChainId: Chain ID retrieval
  • tx: Transaction monitoring utilities
  • events: Event subscription utilities
  • authenticate: User authentication method
  • unauthenticate: User logout method
  • signUserMessage: Message signing method
  • All SDK methods (send, decode, subscribe, etc.)

Rate this page