Delete a Post

This guide will help you delete a post from a Lens Feed.


To delete a post on Lens, you need to:

  1. Delete the Post on-chain

  2. Wait for the transaction to be finalized

  3. Delete the Post content

1

Delete the Post

First, use the deletePost mutation to submit a delete transaction.

Bear in mind that the trail of the Post existance will remain as part of the blockchain history.

mutation {  deletePost(    request: {      post: "42"
      # Optional, any data required by custom Feed Rule      # feedRules: FeedRulesInput    }  ) {    ... on DeletePostResponse {      hash    }
    ... on SponsoredTransactionRequest {      ...SponsoredTransactionRequest    }
    ... on SelfFundedTransactionRequest {      ...SelfFundedTransactionRequest    }
    ... on TransactionWillFail {      reason    }  }}

2

Wait for the Transaction

Then, handle the result as explained in the Transaction Lifecycle guide.

In this example, we will assume the previous step returned a DeletePostResponse object so we will poll the transactionStatus query until it returns a FinishedTransactionStatus result.

Query
query {  transactionStatus(    request: { txHash: "0x5e9d8f8a4b8e4b8e4b8e4b8e4b8e4b8e4b8e4b" }  ) {    ... on NotIndexedYetStatus {      reason      txHasMined    }
    ... on PendingTransactionStatus {      blockTimestamp    }
    ... on FinishedTransactionStatus {      blockTimestamp    }
    ... on FailedTransactionStatus {      reason      blockTimestamp    }  }}

3

Delete the Content

Finally, to delete a Post's content, you must remove the Post Metadata object located at post.contentURI, along with any referenced files.

The deletion process depends on the hosting solution used when the Post was created or last updated. For example, if IPFS was used, you should unpin the content to free up resources.

If you used Lens Storage Nodes, the result of the first step will determine your next steps:

  • If you received a DeletePostResponse, the Lens API has already handled the content deletion for you, and no further action is required.

  • If you received a SponsoredTransactionRequest or SelfFundedTransactionRequest, you will need to delete the content by calling the lens storage nodes. See the Deleting Content guide for more information.