Gated module.

Constructors

Methods

  • Encrypts Publication Metadata with the given access condition.

    ⚠️ Requires authenticated LensClient.

    Type Parameters

    • T extends PublicationMetadata

    Parameters

    • metadata: T
    • condition: AnyCondition

    Returns PromiseResult<T, NotAuthenticatedError | CredentialsExpiredError>

    Example

    Typical usage:

    1. create metadata,
    2. encrypt it,
    3. upload it to a public location (e.g. IPFS, Arweave),
    4. use the resulting contentURI to create a Lens publication.
    // 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

    Example

    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 required
    • eoaOwnershipCondition - the ownership of a given EOA is required
    • erc20OwnershipCondition - the ownership of a given ERC20 amount is required
    • erc721OwnershipCondition - the ownership of a given ERC721 token is required
    • erc1155OwnershipCondition - the ownership of a given ERC1155 token is required
    • profileOwnershipCondition - the ownership of a given profile is required
    • followCondition - following a given profile is required
    • andCondition - 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)

    See

    Metadata helpers for more information on how to create publication metadata and access conditions.