Help & Support

Create a Post

This guide will walk you through the process of creating a Post.

Your First Post

Lens Post content, including text, images, videos, and more, is stored in what's known as Post Metadata. This metadata is a JSON file linked to the Lens Post via its public URI.

To create a Post on Lens, follow these steps:

  1. Create the Post Metadata object.

  2. Upload this object to a publicly accessible URI.

  3. Use this metadata URI to create the Lens Post.

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

1

Create Post Metadata

First, construct a Post Metadata object with the necessary content.

The Post Metadata Standard encompass various types of content. Below is a list of the most common ones.

Used to describe content that is text-only, such as a message or a comment.

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

See textOnly(input): TextOnlyMetadata reference doc.

2

Upload Post Metadata

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

import { textOnly } from "@lens-protocol/metadata";import { storageClient } from "./storage-client";
const metadata = textOnly({  content: `GM! GM!`,});
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

Submit On-Chain

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

Then, use the post action to create a Lens Post.

import { post } from "@lens-protocol/client/actions";

See below examples for creating a Post, Comment, and Quote.

import { uri } from "@lens-protocol/client";
const result = await post(sessionClient, { contentUri: 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 post(sessionClient, { contentUri: uri("lens://4f91ca…") }).andThen(  handleWith(walletClient));

The Lens SDK example here leverages a functional approach to chaining operations using the Result<T, E> object. See the Error Handling guide for more information.

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

Post Rules

Coming soon.

Post Actions

Coming soon.