Skip to main content
info

This package is currently in alpha and is subject to change.

FCL Wagmi Adapter

Provides a Wagmi connector that uses @onflow/fcl-ethereum-provider under the hood, allowing you to integrate Flow-based Cadence-Owned Accounts (COAs) seamlessly into Wagmi applications.

Installation


_10
npm install @onflow/fcl-wagmi-adapter

Usage

Basic Example:


_31
import { createClient, configureChains } from 'wagmi'
_31
import { fclWagmiConnector } from '@onflow/fcl-wagmi-adapter'
_31
import { flowTestnet } from 'wagmi/chains'
_31
import { publicProvider } from 'wagmi/providers/public'
_31
import * as fcl from '@onflow/fcl'
_31
_31
// Configure FCL for Flow
_31
fcl.config({
_31
"accessNode.api": "https://rest-testnet.onflow.org",
_31
"discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn",
_31
})
_31
_31
// Set up Wagmi for Flow Testnet
_31
const { chains, provider } = configureChains(
_31
[flowTestnet],
_31
[publicProvider()]
_31
)
_31
_31
// Create a connector that uses FCL under the hood
_31
const fclConnector = fclWagmiConnector({
_31
// optional: you can pass any config your provider or FCL needs
_31
})
_31
_31
// Create the Wagmi client
_31
const wagmiClient = createClient({
_31
autoConnect: true,
_31
connectors: [fclConnector],
_31
provider,
_31
})
_31
_31
// The rest of your dApp logic...

API

fclWagmiConnector(options?: FclWagmiConnectorOptions): Connector

  • Parameters
    • options?: object – any additional configuration for the underlying FCL provider (gateway URL, custom FCL service, etc.)
  • Returns: A Wagmi Connector object that can be used in createClient or getDefaultConfig.

Notes:

  • This connector essentially wraps @onflow/fcl-ethereum-provider as an EIP-1193 provider to talk to Flow EVM via Wagmi.
  • The user’s authenticated COA is exposed as the “account” in Wagmi context.