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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.createFcl(params)
Or import directly the specific function:
_10import { createFcl } from "@onflow/fcl-core"_10_10createFcl(params)
Usage
_30// Basic FCL instance creation_30import { createFcl } from "@onflow/fcl-core"_30_30const fcl = createFcl({_30 accessNodeUrl: "https://rest-testnet.onflow.org",_30 computeLimit: 1000,_30 flowNetwork: "testnet"_30})_30_30// Use the instance for authentication_30const user = await fcl.currentUser.authenticate()_30console.log("Authenticated user:", user.addr)_30_30// Submit a transaction_30const txId = await fcl.mutate({_30 cadence: `_30 transaction {_30 execute { log("Hello, Flow!") }_30 }_30 `_30})_30_30// Query the blockchain_30const result = await fcl.query({_30 cadence: `_30 pub fun main(): Int {_30 return 42_30 }_30 `_30})
Parameters
params
- Type:
_10WithOptionalProperties<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 queriescustomResolver
- Optional custom resolver for address replacementcustomDecoders
- Optional custom decoders for response parsingcontracts
- Optional contract address mappingsplatform
- Platform identifier (e.g., "web", "mobile", "extension")discoveryWallet
- Optional discovery wallet endpointdiscoveryWalletMethod
- Optional discovery wallet methoddefaultComputeLimit
- Optional default compute limit overrideflowNetwork
- Optional Flow network identifierserviceOpenIdScopes
- Optional OpenID scopes for serviceswalletconnectProjectId
- Optional WalletConnect project IDwalletconnectDisableNotifications
- Optional flag to disable WalletConnect notificationsstorage
- Storage provider for session persistencediscovery
- Optional discovery configuration with execStrategytransport
- 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.)