Delete a Post
This guide will help you delete a post from a Lens Feed.
To delete a post on Lens, you need to:
Delete the Post on-chain
Wait for the transaction to be finalized
Delete the Post content
- GraphQL
- React
- TypeScript
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.
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 } }}
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.