Help & Support

Manage Groups

This guide explains how to manage Groups on Lens.

Update Group Metadata

To update a Group Metadata, follow these steps.

You MUST be authenticated as Builder and be either the owner or an admin of the Group you intend to update.

1

Create New Metadata

First, create a new Group Metadata object with the updated details.

It's developer responsability to copy over any existing data that should be retained.

The process is similar to the one in the Create a Group guide, so we will keep this example brief.

Example
import { group } from "@lens-protocol/metadata";
const metadata = group({  name: "XYZ",  description: "My group description",  icon: "lens://BsdfA…",});

2

Upload Metadata

Next, upload the Group Metadata object to a public URI.

Upload Metadata
import { storageClient } from "./storage-client";
// …
const { uri } = await storageClient.uploadAsJson(metadata);
console.log(uri); // e.g., lens://4f91ca…

If Lens Storage Nodes was used you can also decide to edit the file at the existing URI. See Editing Content guide for more information.

3

Update Metadata URI

Next, update the Group metadata URI with the new URI.

Use the setGroupMetadata action to update the Group Metadata URI.

import { uri } from "@lens-protocol/client";import { setGroupMetadata } from "@lens-protocol/client/actions";
const result = await setGroupMetadata(sessionClient, {  group: group.id,  metadataUri: uri("lens://4f91ca…"),});
if (result.isErr()) {  return console.error(result.error);}

4

Handle Result

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

import { handleOperationWith } from "@lens-protocol/client/viem";
// …
const result = await setGroupMetadata(sessionClient, {  group: group.id,  metadataUri: uri("lens://4f91ca…"),}).andThen(handleOperationWith(walletClient));

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

Access Control

The Group contract supports two roles: Owner and Administrator.

Administrators can:

  • Update the Group Metadata

  • Update the Group Rules

  • Update the Group Extra Data

The Owner can do everything the administrators can do, plus transfer ownership of the Group to another address.

See the Team Management guide for more information on how to manage these roles.