Decrypts a Publication Metadata fragment returned by the Lens API.
⚠️ Requires authenticated LensClient.
The fragment MUST be encrypted. Use the isEncryptedPublicationMetadata type guard to check if the fragment is encrypted.
Typical usage:
LensClient
method,const post = await client.publication.fetch({ forId: '...' });
if (isEncryptedPublicationMetadata(post.metadata)) {
const result = await client.gated.decryptPublicationMetadataFragment(post.metadata);
if (result.isSuccess()) {
console.log(result.value);
}
}
Encrypts Publication Metadata with the given access condition.
⚠️ Requires authenticated LensClient.
Typical usage:
// create publication metadata via '@lens-protocol/metadata' helpers
const metadata = article({ content: '...' });
// encrypt the metadata specifying the access condition
const result = await client.gated.encryptPublicationMetadata(
metadata,
eoaOwnershipCondition({
address: signer.address,
}),
);
const encrypted = result.unwrap();
// upload the encrypted metadata your storage of choice
const contentURI = await uploadToIPFS(encrypted);
// use the contentURI to create a publication
Multiple criteria can be combined using the orCondition
and andCondition
helpers.
const result = await client.gated.encryptPublicationMetadata(
metadata,
orCondition([
profileOwnershipCondition({
profileId: profile.id,
}),
eoaOwnershipCondition({
address: signer.address,
}),
])
);
Supported criteria:
collectCondition
- the collection of a given publication is requiredeoaOwnershipCondition
- the ownership of a given EOA is requirederc20OwnershipCondition
- the ownership of a given ERC20 amount is requirederc721OwnershipCondition
- the ownership of a given ERC721 token is requirederc1155OwnershipCondition
- the ownership of a given ERC1155 token is requiredprofileOwnershipCondition
- the ownership of a given profile is requiredfollowCondition
- following a given profile is requiredandCondition
- up to 5 conditions can be combined using the AND operator (except orCondition
and andCondition
)orCondition
- up to 5 conditions can be combined using the OR operator (except orCondition
and andCondition
)Metadata helpers for more information on how to create publication metadata and access conditions.
Gated module.