Help & Support

Update Account Metadata

This guide will help you update Account details like profile picture, name, and bio.

To update Account Metadata, you need to:

  1. Create a new Account Metadata object.

  2. Upload the Account Metadata object onto a public URI.

  3. Set the URI of the Account Metadata on your Lens Account.

The first two steps are similar to the ones in the Create an Account guide so we'll keep them brief.

See the Lens Metadata Standards guide for more information on creating and hosting Metadata objects.

1

Create Account Metadata

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

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

import { MetadataAttributeType, account } from "@lens-protocol/metadata";
const metadata = account({  name: "Jane Doe",  bio: "I am a photographer based in New York City.",  picture: "lens://4f91cab87ab5e4f5066f878b72…",  coverPicture: "lens://4f91cab87ab5e4f5066f878b78…",  attributes: [    {      key: "twitter",      type: MetadataAttributeType.STRING,      value: "https://twitter.com/janedoexyz",    },    {      key: "dob",      type: MetadataAttributeType.DATE,      value: "1990-01-01T00:00:00Z",    },    {      key: "enabled",      type: MetadataAttributeType.BOOLEAN,      value: "true",    },    {      key: "height",      type: MetadataAttributeType.NUMBER,      value: "1.65",    },    {      key: "settings",      type: MetadataAttributeType.JSON,      value: '{"theme": "dark"}',    },  ],});

2

Upload Account Metadata

Then, upload the Account Metadata object to a public URI.

import { account } from "@lens-protocol/metadata";import { storageClient } from "./storage-client";
const metadata = account({  name: "Jane Doe",});
const { uri } = await storageClient.uploadAsJson(metadata);
console.log(uri); // e.g., lens://4f91ca…

This example uses Lens Storage to host the Metadata object. See the Lens Metadata Standards guide for more information on hosting Metadata objects.

3

Set Account Metadata URI

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

Then, you can use the setAccountMetadata action to update the Account Metadata URI.

Set Account Metadata
import { uri } from "@lens-protocol/client";import { setAccountMetadata } from "@lens-protocol/client/action";
const result = await setAccountMetadata(sessionClient, {  metadataUri: uri("lens://4f91ca…"),});

4

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 setAccountMetadata(sessionClient, {  metadataUri: uri("lens://4f91ca…"),}).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 update metadata for a Lens Account.