You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Authentication in FCL is closely tied to the concept of `currentUser`. In fact, `fcl.authenticate` and `fcl.unauthenticate` are simply aliases for `fcl.currentUser.authenticate()` and `fcl.currentUser.unauthenticate()`, respectively. So, let’s take a closer look at `currentUser`.
3
+
Authentication in Flow Client Library (FCL) is closely tied to the concept of `currentUser`. In fact, `fcl.authenticate` and `fcl.unauthenticate` are simply aliases for `fcl.currentUser.authenticate()` and `fcl.currentUser.unauthenticate()`, respectively. So, let’s take a closer look at `currentUser`.
4
4
5
-
As an onchain app developer using FCL, the primary authentication functionalities revolve around:
5
+
As an onchain app developer who uses FCL, the primary authentication functionalities revolve around how to:
6
6
7
-
-Determining the `currentUser` and whether they are logged in.
8
-
-Logging a user in.
9
-
-Logging a user out.
7
+
-Determine the `currentUser` and whether they are logged in.
8
+
-Log a user in.
9
+
-Log a user out.
10
10
11
-
Due to the way FCL works, logging in and signing up are essentially the same process.
11
+
Due to the way FCL works, to log in and sign up are essentially the same process.
12
12
13
-
# Retrieving Information About the Current User
13
+
# Retrieve information about the current user
14
14
15
15
FCL provides two ways to get information about the current user:
16
16
17
17
1.**A promise-based method** that returns a snapshot of the user’s data.
18
18
2.**A subscription-based method** that triggers a callback function with the latest user information whenever it changes.
The TL;DR: Call `fcl.authenticate()` to log in and `fcl.unauthenticate()` to log out.
43
43
44
-
On Flow mainnet, no additional configuration is needed—your app’s users will go through the authentication process and be able to use any FCL-compatible wallet provider.
44
+
On Flow mainnet, no additional configuration is needed, because your app’s users will go through the authentication process and can use any FCL-compatible wallet provider.
45
45
46
-
During development, you’ll likely want to configure your app to use [`@onflow/dev-wallet`](https://github.com/onflow/fcl-dev-wallet). The [Quick Start](../../../../blockchain-development-tutorials/cadence/getting-started/index.md) guide will walk you through setting it up.
46
+
During development, you’ll likely want to configure your app to use [`@onflow/dev-wallet`]. The [Quick Start] guide will walk you through how to set it up.
47
47
48
-
We also recommend using the [FCL Discovery Service](discovery.md) to help users discover and connect to FCL-compatible wallets.
48
+
We also recommend that you use the [FCL Discovery Service] to help users discover and connect to FCL-compatible wallets.
49
49
50
-
Whether you're new to building onchain, or an established veteran, we’re here to help. If you run into any issues, reach out to us on [Discord](https://discord.gg/flow) — we’re happy to assist!
50
+
Whether you're new to building onchain, or an established veteran, we’re here to help. If you run into any issues, reach out to us on [Discord] — we’re happy to assist!
51
+
52
+
<!-- Reference-style links, will not render on page. -->
Copy file name to clipboardExpand all lines: docs/build/tools/clients/fcl-js/configure-fcl.md
+35-20Lines changed: 35 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,12 @@ title: How to Configure FCL
4
4
5
5
## Configuration
6
6
7
-
FCL provides a mechanism to configure various aspects of its behavior. The key principle is that when switching between different Flow Blockchain environments (e.g., Local Emulator → Testnet → Mainnet), the only required change should be your FCL configuration.
7
+
Flow Client Library (FCL) provides a mechanism to configure various aspects of its behavior. The key principle is that when you switch between different Flow Blockchain environments (for example, Local Emulator → Testnet → Mainnet), the only required change should be your FCL configuration.
8
8
9
-
## Setting Configuration Values
9
+
## Set configuration values
10
+
11
+
Values only need to be set once. We recommend that you do this once and as early in the life cycle as possible.
10
12
11
-
Values only need to be set once. We recommend doing this once and as early in the life cycle as possible.
12
13
To set a configuration value, the `put` method on the `config` instance needs to be called, the `put` method returns the `config` instance so they can be chained.
13
14
14
15
```javascript
@@ -20,11 +21,15 @@ fcl
20
21
.put('baz', 'buz'); // configures "baz" to be "buz"
21
22
```
22
23
23
-
> **Note**: For advanced use cases requiring scoped configuration, isolated client instances, or multi-tenancy support, see the [`createFlowClient` reference documentation](./packages-docs/fcl/createFlowClient.md).
24
+
:::info
25
+
26
+
For advanced use cases that require scoped configuration, isolated client instances, or multi-tenancy support, see the [`createFlowClient` reference documentation].
24
27
25
-
## Getting Configuration Values
28
+
:::
26
29
27
-
The `config` instance has an asynchronous `get` method. You can also pass it a fallback value incase the configuration state does not include what you are wanting.
30
+
## Get configuration values
31
+
32
+
The `config` instance has an asynchronous `get` method. You can also pass it a fallback value in case the configuration state does not include what you want.
-`accessNode.api` -- Api URL for the Flow Blockchain Access Node you want to be communicating with.
50
-
-`app.detail.title` - **(INTRODUCED `@onflow/[email protected]`)** Your applications title, can be requested by wallets and other services. Used by WalletConnect plugin & Wallet Discovery service.
51
-
-`app.detail.icon` - **(INTRODUCED `@onflow/[email protected]`)**Url for your applications icon, can be requested by wallets and other services. Used by WalletConnect plugin & Wallet Discovery service.
52
-
-`app.detail.description` - **(INTRODUCED `@onflow/[email protected]`)** Your applications description, can be requested by wallets and other services. Used by WalletConnect plugin & Wallet Discovery service.
53
-
-`app.detail.url` - **(INTRODUCED `@onflow/[email protected]`)** Your applications url, can be requested by wallets and other services. Used by WalletConnect plugin & Wallet Discovery service.
54
+
-`accessNode.api` -- API URL for the Flow Blockchain Access Node you want to communicate with.
55
+
-`app.detail.title` - **(INTRODUCED `@onflow/[email protected]`)** Your applications title, can be requested by wallets and other services. Used by WalletConnect plugin and Wallet Discovery service.
56
+
-`app.detail.icon` - **(INTRODUCED `@onflow/[email protected]`)**URL for your applications icon, can be requested by wallets and other services. Used by WalletConnect plugin and Wallet Discovery service.
57
+
-`app.detail.description` - **(INTRODUCED `@onflow/[email protected]`)** Your applications description, can be requested by wallets and other services. Used by WalletConnect plugin and Wallet Discovery service.
58
+
-`app.detail.url` - **(INTRODUCED `@onflow/[email protected]`)** Your applications URL, can be requested by wallets and other services. Used by WalletConnect plugin and Wallet Discovery service.
54
59
-`challenge.handshake` -- **(DEPRECATED `@onflow/[email protected]`)** Points FCL at the Wallet or Wallet Discovery mechanism.
55
60
-`discovery.wallet` -- **(INTRODUCED `@onflow/[email protected]`)** Points FCL at the Wallet or Wallet Discovery mechanism.
56
61
-`discovery.wallet.method` -- Describes which service strategy a wallet should use: `IFRAME/RPC`, `POP/RPC`, `TAB/RPC`, `HTTP/POST`, `EXT/RPC`
57
62
-`env` -- **(DEPRECATED `@onflow/[email protected]`)** Used in conjunction with stored interactions. Possible values: `local`, `testnet`, `mainnet`
58
63
-`fcl.limit` -- Specifies fallback compute limit if not provided in transaction. Provided as integer.
59
64
-`flow.network` (recommended) -- **(INTRODUCED `@onflow/[email protected]`)** Used in conjunction with stored interactions and provides FCLCryptoContract address for `testnet` and `mainnet`. Possible values: `local`, `testnet`, `mainnet`.
60
65
-`service.OpenID.scopes` - **(INTRODUCED `@onflow/[email protected]`)** Open ID Connect claims for Wallets and OpenID services.
61
-
-`walletconnect.projectId` -- **(INTRODUCED `@onflow/[email protected]`)** Your app's WalletConnect project ID. See [WalletConnect Cloud](https://cloud.walletconnect.com/sign-in) to obtain a project ID for your application.
66
+
-`walletconnect.projectId` -- **(INTRODUCED `@onflow/[email protected]`)** Your app's WalletConnect project ID. See [WalletConnect Cloud] to obtain a project ID for your application.
62
67
-`walletconnect.disableNotifications` -- **(INTRODUCED `@onflow/[email protected]`)** Flag to disable pending WalletConnect request notifications within the application's UI. Default is `false`.
63
68
64
-
## Using Contracts in Scripts and Transactions
69
+
## Use contracts in scripts and transactions
65
70
66
-
### Address Replacement
71
+
### Address replacement
67
72
68
-
Configuration keys that start with `0x` will be replaced in FCL scripts and transactions, this allows you to write your script or transaction Cadence code once and not have to change it when you point your application at a difference instance of the Flow Blockchain.
73
+
Configuration keys that start with `0x` will be replaced in FCL scripts and transactions. This allows you to write your script or transaction Cadence code once and not have to change it when you point your application at a difference instance of the Flow Blockchain.
69
74
70
75
```javascript
71
76
import*asfclfrom'@onflow/fcl';
@@ -115,9 +120,9 @@ fcl
115
120
.put('0xFlowToken', '0x7e60df042a9c0868');
116
121
```
117
122
118
-
### Using`flow.json`
123
+
### Use`flow.json`
119
124
120
-
A simpler way to import contracts in scripts and transactions is to use the `config.load` method to ingest your contracts from your `flow.json` file. This keeps the import syntax unified across tools and lets FCL figure out which address to use for what network based on the network provided in config. To use `config.load` you must first import your `flow.json` file and then pass it to `config.load` as a parameter.
125
+
A simpler way to import contracts in scripts and transactions is to use the `config.load` method to ingest your contracts from your `flow.json` file. This keeps the import syntax unified across tools and lets FCL figure out which address to use for what network based on the network provided in the config. To use `config.load` you must first import your `flow.json` file and then pass it to `config.load` as a parameter.
121
126
122
127
```javascript
123
128
import { config } from'@onflow/fcl';
@@ -146,6 +151,16 @@ Then in your scripts and transactions, all you have to do is:
146
151
import "HelloWorld"
147
152
```
148
153
149
-
FCL will automatically replace the contract name with the address for the network you are using.
154
+
FCL will automatically replace the contract name with the address for the network you use.
155
+
156
+
:::info
157
+
158
+
Never put private keys in your `flow.json`. Instead, use the [key/location syntax] to separate your keys into a separate git ignored file.
159
+
160
+
:::
161
+
162
+
<!-- Reference-style links, will not render on page. -->
150
163
151
-
> Note: never put private keys in your `flow.json`. You should use the [key/location syntax](../../flow-cli/flow.json/security.md) to separate your keys into a separate git ignored file.
0 commit comments