Comment on page

Lens

The Lens Protocol is a decentralized social graph built on the Polygon blockchain that is modular and composable. The modularity of the protocol is central to its design, making it one of the most competitive social graph protocols in the web3 ecosystem. Developers can obtain information about other modules and relationships bound to Lens protocol modules by querying the protocol, and reverse resolution is also supported.
The community expansion and continued development of new features are core to the Lens Protocol, and all key functions are powered by NFTs, giving users ownership. Here is a brief summary of the main features of the Lens Protocol.

Profile

In order to retrieve data related to Lens, such as assets and relationship data, via an EOA address, it is necessary to first locate the associated profileId by retrieving basic information about Lens using the address. The profileId serves as the key to query Lens-related data. Here is a sample code to illustrate this process.
addrs(where:{address:"0x88520C10ad3d35aD2D3220CdE446CcB33f09331B"}){
lensInclude{
profileId
handle
imageURI
metadata
address
followModule
value
}
}
}

Relationship

The Lens follow relationship is established through the EOA address and profileId of the users involved. This relationship represents the connection between a follower and the user they are following. For instance, if user A is following user B, the actual EOA address of user A will be bound to user B's profileId. To determine which Lens users are being followed by user A, it is necessary to query their EOA addresses. Here is a sample code that demonstrates this query process.
{
addrs(where:{address:"0x88520C10ad3d35aD2D3220CdE446CcB33f09331B"}){
lensInclude{
profileId
handle
imageURI
metadata
address
followModule
value
}
followLens{ #check handles followed by this address
profileId
handle
imageURI
metadata
address
followModule
value
}
followLensAggregate{ # aggregation search
count
}
}
}

Follower

To retrieve information about followers on a Lens account, it is necessary to conduct a query based on the Lens profileId or handle. This query will ultimately yield the EOA addresses of the followers associated with the account. Below is a sample code demonstrating the query process.
{
lens(where:{profileId:104724}){ # query based on profileId/handle
profileId
handle
address
metadata
imageURI
# followers, limit for the number of limit (default 10), offset is the paging query
followerAddrs(options:{limit:5,offset:1}){
address
}
followerAddrsAggregate{
count
}
}
}

Publishment List

The Lens pub of a given Lens account houses all of the NFT data associated with that account. To query the Lens pub, it is necessary to use either the Lens profileId or handle as a basis for the query. Below is a sample code demonstrating how to conduct this query.
{
lens(where:{profileId:104724}){ # query based on profileId/handle
profileId
handle
address
publishComments(options:{limit:5,offset:1}){ # each pub can be queried with paging
profileId
pubId
profileIdPointed # for which user to comment
pubIdPointed # for which pub of users to comment
contentURI # access the actual user comment data through this url
timestamp
}
publishMirrors{
pubId
profileId
profileIdPointed # for which user to mirror
pubIdPointed # for which pub of users to mirror
contentURI
timestamp
}
publishPosts{
pubId
profileId
contentURI
timestamp
}
}
}

Publishment Details

To quickly access specific information about a pub, it is possible to conduct a query using both the Lens profileId and pubId. This query will ultimately provide a complete export of all information associated with the Lens pub. Below is a sample code demonstrating how to conduct this query.
{
lens_post(where:{profileId:104724,pubId:27}){
id
profileId
pubId
contentURI
}
lens_comment(where:{profileId:104724,pubId:19}){
contentURI
timestamp
pubIdPointed
profileIdPointed
}
lens_mirror(where:{profileId:104724,pubId:12}){
contentURI
timestamp
pubIdPointed
profileIdPointed
}
}