NFT Galleries
Learn how to create and manage curated NFT galleries.
Create and manage curated NFT galleries. This off-chain feature allows a Profile to showcase their favorite NFTs to other Lens users.
Get Galleries
Fetch the NFT galleries associated with a given Profile ID.
- React SDK
- JavaScript SDK
- API
You can utilize the client.nfts.fetchGalleries method to retrieve NFT galleries.
import { development, LensClient } from '@lens-protocol/client';
const client = new LensClient({ environment: development,});
const result = await client.nfts.fetchGalleries({ for: "0x01", // Profile ID});
The method returns a PaginatedResult<NftGalleryFragment>. For more information on pagination, refer to this guide.
New Gallery
This feature allows you to create a new NFT Gallery for the authenticated profile. Each gallery has a name and a list of NFTs. NFTs are uniquely identified by a combination of contract.address, contract.chainId, and tokenId.
You must be authenticated with a Profile to create an NFT Gallery. See Profile Login for more information.
You can find NFTs owned by a Profile using the nfts query. Read more about this here. Upon successful creation, this mutation returns the Gallery Id.
- React SDK
- JavaScript SDK
- API
You can utilize the client.nfts.createGallery method to create a new NFT Gallery.
const result = await client.nfts.createGallery({ name: 'My favorite NFTs', items: [ { contract: { address: '0x1234123412341234123412341234123412341234', // an NFT that wallet owns chainId: 5, }, tokenId: '1', }, ],});
Please note that the creation of an NFT Gallery will fail if you attempt to add NFTs that your wallet does not own.
Update Gallery
Update Name
This feature allows you to modify the name of your existing NFT Gallery.
You must be authenticated with a Profile to update an NFT Gallery. See Profile Login for more information.
- React SDK
- JavaScript SDK
- API
You can utilize the client.nfts.updateGalleryInfo method to modify the name of an existing NFT Gallery.
const result = await client.nfts.updateGalleryInfo({ galleryId: 'GALLERY_ID', name: 'My favorite NFTs',});
Update Items
This feature allows you to add or remove NFTs from an existing NFT Gallery. You can perform single or multiple updates within a single request.
You must be authenticated with a Profile to update NFT gallery items. See Profile Login for more information.
- React SDK
- JavaScript SDK
- API
You can utilize the client.nfts.updateGalleryItems method to add or remove items from an existing NFT Gallery.
const result = await client.nfts.updateGalleryItems({ galleryId: 'GALLERY_ID', toAdd: [ { contract: { address: '0x1234123412341234123412341234123412341234', // an NFT that wallet owns chainId: 5, }, tokenId: '1', }, ], toRemove: [ { contract: { address: '0x1234123412341234123412341234123412341234', // an NFT that wallet owns chainId: 5, }, tokenId: '2', }, ],});
Update Order
This feature allows you to rearrange the order of items within an NFT Gallery. You can perform single or multiple updates within a single request. Each update places the specified NFT at the newOrder position, shifting other items before and after it accordingly.
You must be authenticated with a Profile to update NFT gallery order. See Profile Login for more information.
- React SDK
- JavaScript SDK
- API
You can utilize the client.nfts.updateGalleryOrder method to rearrange the order of items within an NFT Gallery.
const result = await client.nfts.updateGalleryOrder({ galleryId: 'GALLERY_ID', updates: [ { contract: { address: '0x1234123412341234123412341234123412341234', // an NFT that wallet owns chainId: 5, }, tokenId: '1', newOrder: 1, }, ],});
Delete Gallery
This feature allows you to delete your NFT Galleries.
You must be authenticated with a Profile to delete your NFT gallery. See Profile Login for more information.
- React SDK
- JavaScript SDK
- API
You can utilize the client.nfts.deleteGallery method to remove an NFT Gallery.
const result = await client.nfts.deleteGallery({ galleryId: 'GALLERY_ID',});