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.
- GraphQL
- React
- TypeScript
Then, you can use the setAccountMetadata mutation to update the Account Metadata URI.
You MUST be authenticated as Account Owner or Account Manager to make this request.
Finally, handle the result as explained in the Transaction Lifecycle guide.
That's it—you now know how to update metadata for a Lens Account.