Metadata Standards

This guide explain how Metadata objects are created and managed in Lens.


Lens Metadata Standards, introduced in LIP-2, are a set of self-describing object specifications. These standards ensure that the data includes all the necessary information for validation within itself.

Create Metadata Object

You can construct Metadata objects in two ways:

  • By utilizing the @lens-protocol/metadata package

  • Manually, with the help of a dedicated JSON Schema

Install the @lens-protocol/metadata package with its required peer dependencies:

npm install zod @lens-protocol/metadata@next

Each guide will detail the Metadata object required for the specific use case. In this guide, we will use a few examples to provide practical methods for creating Metadata objects.

import { textOnly } from "@lens-protocol/metadata";
const metadata = textOnly({  content: `GM! GM!`,});

Host Metadata Objects

You can use the Lens Storage Nodes to host your Metadata objects in a cheap and safe way.

In general you can host Metadata anywhere (e.g., IPFS, Arweave, AWS S3), as long as it's publicly accessible via a URI and served with the appropriate Content-Type: application/json header.

In the examples throughout the documentation, we'll presume the existence of an uploadJson function. This function takes any JavaScript object, uploads it, and subsequently returns the public URI of the uploaded file.

import { account } from "@lens-protocol/metadata";import { uploadJson } from "./my-upload-lib";
const metadata = account({  name: "Jane Doe",});
const metadataURI = await uploadJson(metadata);

You can also upload media files to the same hosting solution, then reference their URIs in the Metadata prior to uploading it.