Custom Modules Overview

Learn how to extend Lens Protocol functionality with Custom Modules.

Modules are a crucial part of the Lens Protocol. They allow to add unique, custom functionality for following, referencing (i.e., mirrors, quotes, and comments), and acting on a publication. This capability paves the way for exciting new community-created features that significantly enhance the basic Lens Protocol social graph!

From a technical perspective, modules are smart contracts that adhere to a specified interface and are invoked at defined execution steps. In other words, modules provide code similar to "hooks" that run at predetermined points.

Follow Modules

Follow Modules are executed when a user attempts to follow a profile. Profile owners can set their Follow Module at profile creation and can change it at any time thereafter. Profile owners can also choose to have no follow module, allowing anyone to follow them without any restrictions or additional actions.

These modules enable logic such as a "fee-on-follow" or even a "subscription" mechanism—and virtually anything else you can conceive!

Reference Modules

Reference Modules are executed when a profile attempts to reference a given profile's publication. These are set once at publication creation and are immutable! However, publications can opt to have no reference module, allowing any profile to comment, quote, or mirror the publication.

Custom rule sets can be built for reference modules—for example, you may want to allow only specific Follower NFT ID holders to comment and follow. In addition, reference modules include separate functions for validating mirrors, quotes, and comments, so the rules can be different for each!

Open Action Modules

Open Actions modules (also known as Publication Open Action Modules at contracts level) are executed when a user wants to act on a given publication. These are set once at publication creation and are immutable! Moreover, publications can have multiple Open Actions attached to them.

There's a plethora of possibilities that can be built with publication action modules:

  • collect

  • donate or tip

  • mint an NFT directly from the post promoting it

  • buy user's shares

  • stake

  • vote on publication's poll

  • join an on-chain raffle

  • etc.

Open Actions offer immense freedom, so the only limiting factor is your imagination!

Referral System

Reference and Open Action Modules can leverage the built-in referral system. This allows, for example, to pass a list of Profile or Publication ID(s) as part of the module execution data.

The Referral System automatically verifies the validity of the passed referral ID(s) and can be used to implement referral rewards, referral bonuses, etc.

See the Referral System section for more details.