Block Accounts
This guide explains how to block and unblock an Account on Lens.
A Lens Account can block other Lens accounts from interacting with them, directly or indirectly. This is achieved by rejecting on-chain transactions that involve the blocking Account.
The Lens API also honors the block status in features that are currently off-chain, such as reactions.
Fetch Blocked Accounts
- TypeScript
- GraphQL
- React
Use the paginated fetchAccountsBlocked action to get a list of accounts that are blocked by the current account.
Example
import { fetchAccountsBlocked } from "@lens-protocol/client/actions";
const result = await fetchAccountsBlocked(client);
if (result.isErr()) { return console.error(result.error);}
// items: Array<AccountBlocked>: [{blockedAt: Date, account: Account}, ...]const { items, pageInfo } = result.value;
Continue with the Pagination guide for more information on how to handle paginated results.
Block Account
You MUST be authenticated as Account Owner or Account Manager to make this request.
- TypeScript
- GraphQL
- React
Use the blockAccount action to block an account.
Block Account
import { evmAddress } from "@lens-protocol/client";import { blockAccount } from "@lens-protocol/client/actions";
const result = await blockAccount(sessionClient, { account: evmAddress("0x1234..."),});
if (result.isErr()) { return console.error(result.error);}
- TypeScript
- GraphQL
- React
Then, handle the result using the adapter for the library of your choice:
See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.
That's it—the account is now blocked.
Unblock Account
You MUST be authenticated as Account Owner or Account Manager to make this request.
- TypeScript
- GraphQL
- React
Use the unblockAccount action to unblock an account.
Unblock Account
import { evmAddress } from "@lens-protocol/client";import { unblockAccount } from "@lens-protocol/client/actions";
const result = await unblockAccount(sessionClient, { account: evmAddress("0x1234..."),});
if (result.isErr()) { return console.error(result.error);}
- TypeScript
- GraphQL
- React
Then, handle the result using the adapter for the library of your choice:
See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.
That's it—the account is now unblocked.