Help & Support

Follow and Unfollow

This guide explains how to follow and unfollow an Account on Lens.

Lens Account can follow other Lens accounts on the Global Graph or on Custom Graphs.

Follow operations are regulated by Follow Rules set on the target Account and by the Graph Rule of the Graph where the follow relationship is established. More information on this will be provided in due course.

Follow an Account

To follow an account, you need to:

  1. Check Follow permissions

  2. Submit a Follow request

All steps in this section assumes are authenticated as Account Owner or Account Manager.

1

Check Follow Permissions

First, inspect the account's operations.canFollow field to determine if you can follow the account.

Account
fragment Account on Account {  # ...
  operations {    # defaults to the Global Graph    canFollow    isFollowedByMe
    # or use aliases for a specific Graph    # canFollowOnMyGraph: canFollow(request: { graph: "0x123…" })    # isFollowedByMeOnMyGraph: isFollowedByMe(request: { graph: "0x123…" })
    # ...  }}

The value of which can be:

  • YES - Your Account meets the follow criteria the target Account Owner has set.

  • NO - You cannot follow the target Account. This could be for 2 reasons:
    • Your Account already follows the target Account, in this case the operation.isFollowedByMe field will be true.

    • Your Account does not meet the follow criteria the target Account Owner has set.

  • UNKNWOWN - Indicates the Account's follow permissions are not known. This could be due to the use of a Custom Follow Rule (more on this later).

2

Submit Follow Request

Then, if your follow request is allowed, you can proceed with submitting the request.

You MUST be authenticated as Account Owner or Account Manager to make this request.

Then, use the follow action with the target Account address.

import { evmAddress } from "@lens-protocol/client";import { follow } from "@lens-protocol/client/actions";
const result = await follow(sessionClient, { account: evmAddress("0x1234") });

The Lens SDK example here leverages a functional approach to chaining operations using the Result<T, E> object. See the Error Handling guide for more information.

3

Handle Result

Finally, handle the result using the adapter for the library of your choice:

import { handleWith } from "@lens-protocol/client/viem";
// …
const result = await follow(sessionClient, { account: evmAddress("0x1234") }).andThen(  handleWith(walletClient),);

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.

Unfollow an Account

To unfollow an account, you need to:

  1. Check Unfollow permissions

  2. Submit an Unfollow request

All steps in this section assumes are authenticated as Account Owner or Account Manager.

1

Check Unfollow Permissions

First, inspect the account's operations.canUnfollow field to determine if you can unfollow the account.

Account
fragment Account on Account {  # ...
  operations {    # defaults to the Global Graph    canUnfollow    isFollowedByMe
    # or use aliases for a specific Graph    # canUnfollowOnMyGraph: canUnfollow(request: { graph: "0x123…" })    # isFollowedByMeOnMyGraph: isFollowedByMe(request: { graph: "0x123…" })  }}

If true, you can unfollow the account. If false, you might not be following them, in which case the operation.isFollowedByMe field will also be false.

2

Submit Unfollow Request

Then, if your unfollow request is allowed, you can proceed with submitting the request.

You MUST be authenticated as Account Owner or Account Manager to make this request.

Then, use the unfollow action with the target Account address.

import { evmAddress } from "@lens-protocol/client";import { unfollow } from "@lens-protocol/client/actions";
const result = await unfollow(sessionClient, { account: evmAddress("0x1234") });

The Lens SDK example here leverages a functional approach to chaining operations using the Result<T, E> object. See the Error Handling guide for more information.

3

Handle Result

Finally, handle the result using the adapter for the library of your choice:

import { handleWith } from "@lens-protocol/client/viem";
// …
const result = await unfollow(sessionClient, { account: evmAddress("0x1234") }).andThen(  handleWith(walletClient),);

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.


That's it—you now know how to follow and unfollow an Account on Lens, allowing to manage social connections.