Lens Protocol

The Lens Protocolarrow-up-right is a Web3 social graph on the Polygon Proof-of-Stake blockchain. It is designed to empower creators to own the links between themselves and their community, forming a fully composable, user-owned social graph. The point of this guide is a focused guide showing how to create and store your post metadata on IPFS/Arweave via 4EVERLAND.For additional information about creating a post on Lens, please visit the lens documentsarrow-up-right.What you can expect in this tutorial:

  1. Use 4EVERLAND to upload post assets to IPFS/Arweave.

  2. Generate structured metadataarrow-up-right for your post and upload it to IPFS/Arweave using 4EVERLAND.

  3. When generating a new Lens Protocol post, use the URL created in the previous step as the content URI.

Upload media to IPFS/Arweave

If your social post involves images, video or audio files, you can upload your files to IPFS/Arweave via 4EVERLAND in a number of optional ways:

Either way, after you have uploaded the files, you can get the cid/arhash of the files and place them in the metadata.

Find the cases used in Lenster and Lenstube:

https://github.com/lensterxyz/lenster/pull/954arrow-up-right

https://github.com/lenstube-xyz/lenstube/blob/main/packages/utils/functions/uploadToIPFS.tsarrow-up-right

Uploading Metadata

You can find out how to create almost any type of post in the full Lens Protocol metadata specificationarrow-up-right. In this case, we assume that we have an image post which is stored in IPFS. The metadata is as follows:

  • The function uuid() generates a unique post id using the UUID npm packagearrow-up-right.

  • If the image is stored in Arweave, please replace the url in the metadata involving the image with the Arweave hash, e.g: https://arweave.net/CO9EpX0lekJEfXUOeXncUmMuG8eEp5WJHXl9U9yZUYA.

Uploading structured JSON data to IPFS/Arweave using 4EVERLAND is a breeze. The following is an example of taking a metadata stringfy and uploading it to the 4EVERLAND Bucket via the AWS-S3 API.

If you want to store your metadata on Arweave, you will need to turn on "Sync to AR" in the Dashboard.

Creating A Post

After successfully uploading your metadata, you can convert the cid or arhash of the metadata to contentURI.The contentURI can be an IPFS or Arweave hash, formatted as follows:

Lastly, generate a post request with the created content URI and send it to the Lens contract calling via the.post() or.postWithSig() functions.

To conclude

That's it! You have just used a few lines of code to combine 4EVERLAND + Lens Protocol to create and store your post metadata on IPFS and Arweave.

Last updated