Skip to content

Commit 00f7a52

Browse files
authored
Merge pull request #1612 from onflow/fcl_js_basic_docs_cws
fcl-js doc edits
2 parents f0daebb + 1c1c244 commit 00f7a52

File tree

10 files changed

+321
-208
lines changed

10 files changed

+321
-208
lines changed
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Authentication
22

3-
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`.
44

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:
66

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.
1010

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.
1212

13-
# Retrieving Information About the Current User
13+
# Retrieve information about the current user
1414

1515
FCL provides two ways to get information about the current user:
1616

1717
1. **A promise-based method** that returns a snapshot of the user’s data.
1818
2. **A subscription-based method** that triggers a callback function with the latest user information whenever it changes.
1919

20-
### Snapshot of the Current User
20+
### Snapshot of the current user
2121

2222
```javascript
2323
import * as fcl from '@onflow/fcl';
@@ -37,14 +37,21 @@ const unsubscribe = fcl.currentUser.subscribe((currentUser) => {
3737
});
3838
```
3939

40-
# Authenticating and Unauthenticating
40+
# Authenticate and unauthenticate
4141

4242
The TL;DR: Call `fcl.authenticate()` to log in and `fcl.unauthenticate()` to log out.
4343

44-
On Flow mainnet, no additional configuration is neededyour 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.
4545

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.
4747

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.
4949

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. -->
53+
54+
[`@onflow/dev-wallet`]: https://github.com/onflow/fcl-dev-wallet
55+
[Quick Start]: ../../../../blockchain-development-tutorials/cadence/getting-started/index.md
56+
[FCL Discovery Service]: discovery.md
57+
[Discord]: https://discord.gg/flow

docs/build/tools/clients/fcl-js/configure-fcl.md

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ title: How to Configure FCL
44

55
## Configuration
66

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.
88

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.
1012

11-
Values only need to be set once. We recommend doing this once and as early in the life cycle as possible.
1213
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.
1314

1415
```javascript
@@ -20,11 +21,15 @@ fcl
2021
.put('baz', 'buz'); // configures "baz" to be "buz"
2122
```
2223

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].
2427

25-
## Getting Configuration Values
28+
:::
2629

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.
2833

2934
```javascript
3035
import * as fcl from '@onflow/fcl';
@@ -44,28 +49,28 @@ async function addStuff() {
4449
addStuff().then((d) => console.log(d)); // 13 (5 + 7 + 1)
4550
```
4651

47-
## Common Configuration Keys
52+
## Common configuration keys
4853

49-
- `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.
5459
- `challenge.handshake` -- **(DEPRECATED `@onflow/[email protected]`)** Points FCL at the Wallet or Wallet Discovery mechanism.
5560
- `discovery.wallet` -- **(INTRODUCED `@onflow/[email protected]`)** Points FCL at the Wallet or Wallet Discovery mechanism.
5661
- `discovery.wallet.method` -- Describes which service strategy a wallet should use: `IFRAME/RPC`, `POP/RPC`, `TAB/RPC`, `HTTP/POST`, `EXT/RPC`
5762
- `env` -- **(DEPRECATED `@onflow/[email protected]`)** Used in conjunction with stored interactions. Possible values: `local`, `testnet`, `mainnet`
5863
- `fcl.limit` -- Specifies fallback compute limit if not provided in transaction. Provided as integer.
5964
- `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`.
6065
- `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.
6267
- `walletconnect.disableNotifications` -- **(INTRODUCED `@onflow/[email protected]`)** Flag to disable pending WalletConnect request notifications within the application's UI. Default is `false`.
6368

64-
## Using Contracts in Scripts and Transactions
69+
## Use contracts in scripts and transactions
6570

66-
### Address Replacement
71+
### Address replacement
6772

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.
6974

7075
```javascript
7176
import * as fcl from '@onflow/fcl';
@@ -115,9 +120,9 @@ fcl
115120
.put('0xFlowToken', '0x7e60df042a9c0868');
116121
```
117122

118-
### Using `flow.json`
123+
### Use `flow.json`
119124

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.
121126

122127
```javascript
123128
import { config } from '@onflow/fcl';
@@ -146,6 +151,16 @@ Then in your scripts and transactions, all you have to do is:
146151
import "HelloWorld"
147152
```
148153

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. -->
150163

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.
164+
[`createFlowClient` reference documentation]: ./packages-docs/fcl/createFlowClient.md
165+
[WalletConnect Cloud]: https://cloud.walletconnect.com/sign-in
166+
[key/location syntax]: ../../flow-cli/flow.json/security.md

0 commit comments

Comments
 (0)