This package is currently in alpha and is subject to change.
FCL Ethereum Provider
Exposes a client-side EIP-1193 compatible Ethereum provider that uses an FCL-authenticated Cadence Owned Account (COA) under the hood. If a wallet does not natively provide EVM capabilities, this provider emulates Ethereum JSON-RPC by delegating to FCL for signing and COA interactions.
Installation
Usage
API
createEthereumProvider(config?: CreateEthereumProviderConfig): Eip1193Provider
-
Parameters
config.service?: Service
An [FCL “Service” object][fcl-service-docs] for custom FCL authentication flows. If omitted, the default FCL discovery service is used.config.gateway?: Eip1193Provider | string
An EIP-1193 provider (or a string URL) pointing to a Flow EVM gateway. Defaults to the public Flow EVM gateway if omitted.
-
Returns: An EIP-1193 provider instance you can pass into EVM tooling or interact with directly in your app.
Supported JSON-RPC Methods
Below are the main request methods handled within the FCL Ethereum provider:
-
eth_requestAccounts
/eth_accounts
- Behavior:
- Invokes the FCL authentication flow (if not already authenticated)
- Returns the Cadence-Owned Account (COA) address
- Stores the COA at
/storage/evm
(creates if missing)
- Behavior:
-
eth_sendTransaction
- Behavior:
- Wraps the transaction in a Cadence transaction that invokes
coa.call(...)
in the Flow EVM - Uses the user’s authenticated COA for signing
- Returns the resulting EVM transaction hash
- Wraps the transaction in a Cadence transaction that invokes
- Behavior:
-
personal_sign
- Behavior:
- Requests a user signature via FCL’s
signUserMessage
or equivalent mechanism - Returns an RLP-encoded COA ownership proof in place of a raw secp256k1 signature
- Requests a user signature via FCL’s
- Behavior:
-
eth_signTypedData_v4
- Behavior:
- Requests user signature for typed data (hash) via FCL
- Returns an RLP-encoded COA ownership proof
- Behavior:
-
eth_chainId
- Behavior:
- Returns the numeric Flow EVM chain ID (e.g.,
0x747
for Flow EVM Mainnet)
- Returns the numeric Flow EVM chain ID (e.g.,
- Behavior:
-
wallet_switchEthereumChain
- Behavior:
- Allows dApps to request switching to a different Flow EVM chain (e.g. testnet to mainnet).
- Under the hood, this can trigger reconfiguration of FCL for a different Flow access node and Flow EVM gateway if recognized.
- If the requested chain ID is not recognized, the call will throw an error (matching EIP-1193 standard error codes).
- Behavior:
-
wallet_addEthereumChain
- Behavior:
- Allows a dApp to request adding a Flow EVM chain config.
- If the chain is recognized by the provider or is one the provider can handle, it will register it. Otherwise, it may reject with an EIP-1193 error.
- Since Flow EVM is typically a single chain per environment, usage is limited. However, in principle, custom EVM networks or local dev can be added if your provider/gateway supports them.
- Behavior:
Fallback Behavior
Any unknown or unsupported request methods will be proxied to the gateway
(if you provided a standard JSON-RPC URL or EIP-1193 provider). If the gateway does not handle them, an error will be returned.
Provider Events
connect
: Emitted once the user successfully authenticates via FCL, indicating that the provider is ready.disconnect
: Emitted if the FCL session ends or user explicitly logs out, severing the session.accountsChanged
: Emitted when the current user changes (e.g. re-authentication, or switching user in the wallet).chainChanged
: Emitted when the user switches to a different Flow EVM chain (e.g. testnet to mainnet).