Update Account Metadata
This guide will help you update Account details like profile picture, name, and bio.
To update Account Metadata, you need to:
Create a new Account Metadata object.
Upload the Account Metadata object onto a public URI.
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.
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.
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.
You MUST be authenticated as Account Owner or Account Manager to make this request.
- TypeScript
- GraphQL
- React
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…"),});
- TypeScript
- GraphQL
- React
Finally, 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—you now know how to update metadata for a Lens Account.