@@@@@@@@@
                                        @@@@@@@@@@@@@@@@@@@@@
                                    @@@@@@@@@@@@@@@@@@@@@@@@@@@@
                                  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                                @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
              @@@@@@@@@@@       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      @@@@@@@@@@@
        @@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@
      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@              @@@@@@@@@@@@@@              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@          @@@@@@@   @@@@@@@@@         @@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@@@@@@  @@        @@@@@@@@  @@@@@@   @       @@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                                  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Lens Protocol

The Lens Protocol is a decentralized, non-custodial social graph. Lens implements unique, on-chain social interaction mechanisms analogous to commonly understood Web2 social media interactions, but significantly expanded with unique functionality that empower communities to form and participants to own their own social graph.

Cloning

You must clone the repo using SSH:

git clone [email protected]:lens-protocol/core-private.git

Setup

  1. Install Foundry by following the instructions from their repository.
    • curl -L https://foundry.paradigm.xyz | bash
    • foundryup
    • done
  2. Install the dependencies by running : npm i && forge install

You can now build it using:

npm run build

Testing

You can run unit tests using

npm run test

Coverage

You can run coverage using

npm run coverage

You can go to our docs to learn more about Lens Protocol.

Contents

Contents

FollowNFTProxy

Git Source

Inherits: Proxy

State Variables

HUB

address immutable HUB;

Functions

constructor

constructor(bytes memory data);

_implementation

function _implementation() internal view override returns (address);

VersionedInitializable

Git Source

Author: Lens Protocol, inspired by Aave's implementation, which is in turn inspired by OpenZeppelin's Initializable contract

Helper contract to implement initializer functions. To use it, replace the constructor with a function that has the initializer modifier. WARNING: Unlike constructors, initializer functions must be manually invoked. This applies both to deploying an Initializable contract, as well as extending an Initializable contract via inheritance. WARNING: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or ensure that all initializers are idempotent, because this is not dealt with automatically as with constructors. This is slightly modified from Aave's version.

State Variables

originalImpl

address private immutable originalImpl;

Functions

initializer

Modifier to use in the initializer function of a contract.

modifier initializer();

constructor

constructor();

getRevision

returns the revision number of the contract Needs to be defined in the inherited class as a constant.

function getRevision() internal pure virtual returns (uint256);

ERC2981CollectionRoyalties

Git Source

Inherits: IERC2981

State Variables

BASIS_POINTS

uint16 internal constant BASIS_POINTS = 10000;

INTERFACE_ID_ERC2981

bytes4 internal constant INTERFACE_ID_ERC2981 = 0x2a55205a;

Functions

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool);

setRoyalty

Changes the royalty percentage for secondary sales.

function setRoyalty(uint256 royaltiesInBasisPoints) external;

Parameters

NameTypeDescription
royaltiesInBasisPointsuint256The royalty percentage (measured in basis points).

royaltyInfo

Called with the sale price to determine how much royalty is owed and to whom.

function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address, uint256);

Parameters

NameTypeDescription
tokenIduint256The ID of the token queried for royalty information.
salePriceuint256The sale price of the token specified.

Returns

NameTypeDescription
<none>addressA tuple with the address that should receive the royalties and the royalty payment amount for the given sale price.
<none>uint256

_setRoyalty

function _setRoyalty(uint256 royaltiesInBasisPoints) internal virtual;

_getRoyaltyAmount

function _getRoyaltyAmount(uint256, uint256 salePrice) internal view virtual returns (uint256);

_storeRoyaltiesInBasisPoints

function _storeRoyaltiesInBasisPoints(uint256 royaltiesInBasisPoints) internal virtual;

_loadRoyaltiesInBasisPoints

function _loadRoyaltiesInBasisPoints() internal view virtual returns (uint256);

_beforeRoyaltiesSet

function _beforeRoyaltiesSet(uint256 royaltiesInBasisPoints) internal view virtual;

_getRoyaltiesInBasisPointsSlot

function _getRoyaltiesInBasisPointsSlot() internal view virtual returns (uint256);

_getReceiver

function _getReceiver(uint256 tokenId) internal view virtual returns (address);

HubRestricted

Git Source

Author: Lens Protocol

This abstract contract adds a public HUB immutable field, as well as an onlyHub modifier, to inherit from contracts that have functions restricted to be only called by the Lens hub.

State Variables

HUB

address public immutable HUB;

Functions

onlyHub

modifier onlyHub();

constructor

constructor(address hub);

LensBaseERC721

Git Source

Inherits: ERC165, ILensERC721

*Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including the Metadata extension, but not including the Enumerable extension, which is available separately as {ERC721Enumerable}. Modifications:

  1. Refactored _operatorApprovals setter into an internal function to allow meta-transactions.
  2. Constructor replaced with an initializer.
  3. Mint timestamp is now stored in a TokenData struct alongside the owner address.*

State Variables

_name

string private _name;

_symbol

string private _symbol;

_tokenData

mapping(uint256 => Types.TokenData) private _tokenData;

_balances

mapping(address => uint256) private _balances;

_tokenApprovals

mapping(uint256 => address) private _tokenApprovals;

_operatorApprovals

mapping(address => mapping(address => bool)) private _operatorApprovals;

__DEPRECATED__ownedTokens

mapping(address => mapping(uint256 => uint256)) private __DEPRECATED__ownedTokens;

__DEPRECATED__ownedTokensIndex

mapping(uint256 => uint256) private __DEPRECATED__ownedTokensIndex;

_totalSupply

uint256 private _totalSupply;

__DEPRECATED__allTokensIndex

mapping(uint256 => uint256) private __DEPRECATED__allTokensIndex;

_nonces

mapping(address => uint256) private _nonces;

Functions

_initialize

Initializes the ERC721 name and symbol.

function _initialize(string calldata name_, string calldata symbol_) internal;

Parameters

NameTypeDescription
name_stringThe name to set.
symbol_stringThe symbol to set.

tokenURI

Returns the Uniform Resource Identifier (URI) for tokenId token.

function tokenURI(uint256 tokenId) external view virtual returns (string memory);

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);

nonces

function nonces(address signer) public view override returns (uint256);

getDomainSeparator

Returns the EIP-712 domain separator for this contract.

function getDomainSeparator() external view virtual override returns (bytes32);

Returns

NameTypeDescription
<none>bytes32bytes32 The domain separator.

balanceOf

See {IERC721-balanceOf}.

function balanceOf(address owner) public view virtual override returns (uint256);

ownerOf

See {IERC721-ownerOf}.

function ownerOf(uint256 tokenId) public view virtual override returns (address);

mintTimestampOf

See {IERC721Timestamped-mintTimestampOf}

function mintTimestampOf(uint256 tokenId) public view virtual override returns (uint256);

tokenDataOf

See {IERC721Timestamped-tokenDataOf}

function tokenDataOf(uint256 tokenId) public view virtual override returns (Types.TokenData memory);

exists

See {IERC721Timestamped-exists}

function exists(uint256 tokenId) public view virtual override returns (bool);

name

See {IERC721Metadata-name}.

function name() public view virtual override returns (string memory);

symbol

See {IERC721Metadata-symbol}.

function symbol() public view virtual override returns (string memory);

totalSupply

function totalSupply() external view virtual override returns (uint256);

approve

See {IERC721-approve}.

function approve(address to, uint256 tokenId) public virtual override;

getApproved

See {IERC721-getApproved}.

function getApproved(uint256 tokenId) public view virtual override returns (address);

setApprovalForAll

See {IERC721-setApprovalForAll}.

function setApprovalForAll(address operator, bool approved) public virtual override;

isApprovedForAll

See {IERC721-isApprovedForAll}.

function isApprovedForAll(address owner, address operator) public view virtual override returns (bool);

transferFrom

See {IERC721-transferFrom}.

function transferFrom(address from, address to, uint256 tokenId) public virtual override;

safeTransferFrom

See {IERC721-safeTransferFrom}.

function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override;

safeTransferFrom

See {IERC721-safeTransferFrom}.

function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override;

burn

*Burns tokenId. Requirements:

  • The caller must own tokenId or be an approved operator.*
function burn(uint256 tokenId) public virtual override;

_unsafeOwnerOf

Returns the owner of the tokenId token.

It is prefixed as unsafe as it does not revert when the token does not exist.

function _unsafeOwnerOf(uint256 tokenId) internal view returns (address);

Parameters

NameTypeDescription
tokenIduint256The token whose owner is being queried.

Returns

NameTypeDescription
<none>addressaddress The address owning the given token, zero address if the token does not exist.

_safeTransfer

*Safely transfers tokenId token from from to to, checking first that contract recipients are aware of the ERC721 protocol to prevent tokens from being forever locked. _data is additional data, it has no specified format and it is sent in call to to. This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. implement alternative mechanisms to perform a token transfer, such as signature-based. Requirements:

  • from cannot be the zero address.
  • to cannot be the zero address.
  • tokenId token must exist and be owned by from.
  • If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual;

_exists

Returns whether tokenId exists. Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (_mint), and stop existing when they are burned (_burn).

function _exists(uint256 tokenId) internal view virtual returns (bool);

_isApprovedOrOwner

*Returns whether spender is allowed to manage tokenId. Requirements:

  • tokenId must exist.*
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool);

_mint

*Mints tokenId and transfers it to to. WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible Requirements:

  • tokenId must not exist.
  • to cannot be the zero address. Emits a {Transfer} event.*
function _mint(address to, uint256 tokenId) internal virtual;

_burn

*Destroys tokenId. The approval is cleared when the token is burned. Requirements:

  • tokenId must exist. Emits a {Transfer} event.*
function _burn(uint256 tokenId) internal virtual;

_transfer

*Transfers tokenId from from to to. As opposed to {transferFrom}, this imposes no restrictions on msg.sender. Requirements:

  • to cannot be the zero address.
  • tokenId token must be owned by from. Emits a {Transfer} event.*
function _transfer(address from, address to, uint256 tokenId) internal virtual;

_approve

Approve to to operate on tokenId Emits a {Approval} event.

function _approve(address to, uint256 tokenId) internal virtual;

_setOperatorApproval

Refactored from the original OZ ERC721 implementation: approve or revoke approval from operator to operate on all tokens owned by owner. Emits a {ApprovalForAll} event.

function _setOperatorApproval(address owner, address operator, bool approved) internal virtual;

_checkOnERC721Received

Private function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract.

function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool);

Parameters

NameTypeDescription
fromaddressaddress representing the previous owner of the given token ID
toaddresstarget address that will receive the tokens
tokenIduint256uint256 ID of the token to be transferred
_databytesbytes optional data to send along with the call

Returns

NameTypeDescription
<none>boolbool whether the call correctly returned the expected magic value

_beforeTokenTransfer

*Hook that is called before any token transfer. This includes minting and burning. Calling conditions:

  • When from and to are both non-zero, from's tokenId will be transferred to to.
  • When from is zero, tokenId will be minted for to.
  • When to is zero, from's tokenId will be burned.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual;

LensGovernable

Git Source

Inherits: ILensGovernable

Functions

onlyGov

This modifier reverts if the caller is not the configured governance address.

modifier onlyGov();

setGovernance

GOV FUNCTIONS ///

function setGovernance(address newGovernance) external override onlyGov;

Parameters

NameTypeDescription
newGovernanceaddressThe new governance address to set.

setEmergencyAdmin

Sets the emergency admin, which is a permissioned role able to set the protocol state.

function setEmergencyAdmin(address newEmergencyAdmin) external override onlyGov;

Parameters

NameTypeDescription
newEmergencyAdminaddressThe new emergency admin address to set.

setState

Sets the protocol state to either a global pause, a publishing pause or an unpaused state.

function setState(Types.ProtocolState newState) external override;

Parameters

NameTypeDescription
newStateTypes.ProtocolStateThe state to set. It can be one of the following: - Unpaused: The protocol is fully operational. - PublishingPaused: The protocol is paused for publishing, but it is still operational for others operations. - Paused: The protocol is paused for all operations.

setTreasury

Sets the treasury address.

function setTreasury(address newTreasury) external override onlyGov;

Parameters

NameTypeDescription
newTreasuryaddressThe new treasury address to set.

setTreasuryFee

Sets the treasury fee.

function setTreasuryFee(uint16 newTreasuryFee) external override onlyGov;

Parameters

NameTypeDescription
newTreasuryFeeuint16The new treasury fee to set.

whitelistProfileCreator

Adds or removes a profile creator from the whitelist.

function whitelistProfileCreator(address profileCreator, bool whitelist) external override onlyGov;

Parameters

NameTypeDescription
profileCreatoraddressThe profile creator address to add or remove from the whitelist.
whitelistboolWhether or not the profile creator should be whitelisted.

getGovernance

EXTERNAL VIEW FUNCTIONS ///

function getGovernance() external view override returns (address);

Returns

NameTypeDescription
<none>addressaddress The address of the currently configured governance.

getState

Returns the current protocol state.

function getState() external view override returns (Types.ProtocolState);

Returns

NameTypeDescription
<none>Types.ProtocolStateProtocolState The Protocol state, an enum, where: 0: Unpaused 1: PublishingPaused 2: Paused

isProfileCreatorWhitelisted

Returns whether or not a profile creator is whitelisted.

function isProfileCreatorWhitelisted(address profileCreator) external view override returns (bool);

Parameters

NameTypeDescription
profileCreatoraddressThe address of the profile creator to check.

Returns

NameTypeDescription
<none>boolbool True if the profile creator is whitelisted, false otherwise.

getTreasury

Returns the treasury address.

function getTreasury() external view override returns (address);

Returns

NameTypeDescription
<none>addressaddress The treasury address.

getTreasuryFee

Returns the treasury fee.

function getTreasuryFee() external view override returns (uint16);

Returns

NameTypeDescription
<none>uint16uint16 The treasury fee.

getTreasuryData

Returns the treasury address and treasury fee in a single call.

function getTreasuryData() external view override returns (address, uint16);

Returns

NameTypeDescription
<none>addresstuple First, the treasury address, second, the treasury fee.
<none>uint16

LensHubEventHooks

Git Source

Inherits: ILensHubEventHooks

Functions

emitUnfollowedEvent

Helper function to emit an Unfollowed event from the hub, to be consumed by indexers to track unfollows.

function emitUnfollowedEvent(uint256 unfollowerProfileId, uint256 idOfProfileUnfollowed, address transactionExecutor)
    external
    override;

Parameters

NameTypeDescription
unfollowerProfileIduint256The ID of the profile that executed the unfollow.
idOfProfileUnfolloweduint256The ID of the profile that was unfollowed.
transactionExecutoraddressThe address of the account executing the unfollow operation.

emitCollectNFTTransferEvent

DEPRECATED FUNCTIONS ///

function emitCollectNFTTransferEvent(uint256 profileId, uint256 pubId, uint256 collectNFTId, address from, address to)
    external;

LensHubStorage

Git Source

Author: Lens Protocol

This is an abstract contract that ONLY contains storage for the LensHub contract. This MUST be inherited last to preserve the LensHub storage layout. Adding storage variables should be done ONLY at the bottom of this contract.

State Variables

_lastInitializedRevision

uint256 private _lastInitializedRevision;

_state

Types.ProtocolState internal _state;

_profileCreatorWhitelisted

mapping(address profileCreator => bool isWhitelisted) internal _profileCreatorWhitelisted;

__DEPRECATED__followModuleWhitelisted

mapping(address => bool isWhitelisted) internal __DEPRECATED__followModuleWhitelisted;

__DEPRECATED__collectModuleWhitelisted

mapping(address collectModule => bool isWhitelisted) internal __DEPRECATED__collectModuleWhitelisted;

__DEPRECATED__referenceModuleWhitelisted

mapping(address referenceModule => bool isWhitelisted) internal __DEPRECATED__referenceModuleWhitelisted;

__DEPRECATED__dispatcherByProfile

mapping(uint256 profileId => address dispatcher) internal __DEPRECATED__dispatcherByProfile;

__DEPRECATED__profileIdByHandleHash

mapping(bytes32 handleHash => uint256 profileId) internal __DEPRECATED__profileIdByHandleHash;

_profiles

mapping(uint256 profileId => Types.Profile profile) internal _profiles;

_publications

mapping(uint256 profileId => mapping(uint256 pubId => Types.Publication publication)) internal _publications;

__DEPRECATED__defaultProfiles

mapping(address userAddress => uint256 profileId) internal __DEPRECATED__defaultProfiles;

_profileCounter

uint256 internal _profileCounter;

_governance

address internal _governance;

_emergencyAdmin

address internal _emergencyAdmin;

_tokenGuardianDisablingTimestamp

mapping(address => uint256) internal _tokenGuardianDisablingTimestamp;

_delegatedExecutorsConfigs

mapping(uint256 profileId => Types.DelegatedExecutorsConfig config) internal _delegatedExecutorsConfigs;

_blockedStatus

mapping(uint256 blockerProfileId => mapping(uint256 blockedProfileId => bool isBlocked)) internal _blockedStatus;

_profileRoyaltiesBps

uint256 internal _profileRoyaltiesBps;

_migrationAdminWhitelisted

mapping(address migrationAdmin => bool allowed) internal _migrationAdminWhitelisted;

_treasuryData

Types.TreasuryData internal _treasuryData;

LensImplGetters

Git Source

Inherits: ILensImplGetters

State Variables

FOLLOW_NFT_IMPL

address internal immutable FOLLOW_NFT_IMPL;

__LEGACY__COLLECT_NFT_IMPL

address internal immutable __LEGACY__COLLECT_NFT_IMPL;

MODULE_REGISTRY

address internal immutable MODULE_REGISTRY;

Functions

constructor

constructor(address followNFTImpl, address collectNFTImpl, address moduleRegistry);

getFollowNFTImpl

Returns the Follow NFT implementation address that is used for all deployed Follow NFTs.

function getFollowNFTImpl() external view override returns (address);

Returns

NameTypeDescription
<none>addressaddress The Follow NFT implementation address.

getLegacyCollectNFTImpl

Returns the Collect NFT implementation address that is used for each new deployed Collect NFT.

function getLegacyCollectNFTImpl() external view override returns (address);

Returns

NameTypeDescription
<none>addressaddress The Collect NFT implementation address.

getModuleRegistry

Returns the address of the registry that stores all modules that are used by the Lens Protocol.

function getModuleRegistry() external view override returns (address);

Returns

NameTypeDescription
<none>addressaddress The address of the Module Registry contract.

LensProfiles

Git Source

Inherits: LensBaseERC721, ERC2981CollectionRoyalties, ILensProfiles

State Variables

TOKEN_GUARDIAN_COOLDOWN

uint256 internal immutable TOKEN_GUARDIAN_COOLDOWN;

Functions

constructor

constructor(uint256 tokenGuardianCooldown);

whenNotPaused

modifier whenNotPaused();

onlyProfileOwner

modifier onlyProfileOwner(address expectedOwner, uint256 profileId);

onlyEOA

modifier onlyEOA();

getTokenGuardianDisablingTimestamp

Returns the timestamp at which the Token Guardian will become effectively disabled.

function getTokenGuardianDisablingTimestamp(address wallet) external view returns (uint256);

Parameters

NameTypeDescription
walletaddressThe address to check the timestamp for.

Returns

NameTypeDescription
<none>uint256uint256 The timestamp at which the Token Guardian will become effectively disabled. Zero if enabled.

DANGER__disableTokenGuardian

DANGER: Triggers disabling the profile protection mechanism for the msg.sender, which will allow transfers or approvals over profiles held by it. Disabling the mechanism will have a 7-day timelock before it becomes effective, allowing the owner to re-enable the protection back in case of being under attack. The protection layer only applies to EOA wallets.

function DANGER__disableTokenGuardian() external onlyEOA;

enableTokenGuardian

Enables back the profile protection mechanism for the msg.sender, preventing profile transfers or approvals (except when revoking them). The protection layer only applies to EOA wallets.

function enableTokenGuardian() external onlyEOA;

burn

Burns a profile, this maintains the profile data struct.

function burn(uint256 tokenId)
    public
    override(LensBaseERC721, IERC721Burnable)
    whenNotPaused
    onlyProfileOwner(msg.sender, tokenId);

tokenURI

Overrides the ERC721 tokenURI function to return the associated URI with a given profile.

function tokenURI(uint256 tokenId) public view override(LensBaseERC721, IERC721Metadata) returns (string memory);

approve

function approve(address to, uint256 tokenId) public override(LensBaseERC721, IERC721);

setApprovalForAll

function setApprovalForAll(address operator, bool approved) public override(LensBaseERC721, IERC721);

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(LensBaseERC721, ERC2981CollectionRoyalties, IERC165)
    returns (bool);

_hasTokenGuardianEnabled

function _hasTokenGuardianEnabled(address wallet) internal view returns (bool);

_getRoyaltiesInBasisPointsSlot

function _getRoyaltiesInBasisPointsSlot() internal pure override returns (uint256);

_getReceiver

function _getReceiver(uint256) internal view override returns (address);

_beforeRoyaltiesSet

function _beforeRoyaltiesSet(uint256) internal view override;

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override whenNotPaused;

Contents

ICollectModule

Git Source

Author: Lens Protocol

This is the standard interface for all Lens-compatible CollectModules. Collect modules allow users to execute custom logic upon a collect action over a publication, like:

  • Only allow the collect if the collector is following the publication author.
  • Only allow the collect if the collector has made a payment to
  • Allow any collect but only during the first 24 hours.
  • Etc.

Functions

initializePublicationCollectModule

Initializes data for a given publication being published.

function initializePublicationCollectModule(
    uint256 profileId,
    uint256 pubId,
    address transactionExecutor,
    bytes calldata data
) external returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
transactionExecutoraddressThe owner or an approved delegated executor.
databytesArbitrary data passed from the user! to be decoded.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processCollect

Processes a collect action for a given publication.

function processCollect(Types.ProcessCollectParams calldata processCollectParams) external returns (bytes memory);

Parameters

NameTypeDescription
processCollectParamsTypes.ProcessCollectParamsThe parameters for the collect action.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

ICollectNFT

Git Source

Author: Lens Protocol

This is the interface for the CollectNFT contract. Which is cloned upon the first collect for any given publication.

Functions

initialize

Initializes the collect NFT, setting the feed as the privileged minter, storing the collected publication pointer and initializing the name and symbol in the LensNFTBase contract.

function initialize(uint256 profileId, uint256 pubId) external;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile in the hub that this Collect NFT points to.
pubIduint256The profile publication ID in the hub that this Collect NFT points to.

mint

Mints a collect NFT to the specified address. This can only be called by the hub and is called upon collection.

function mint(address to) external returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the NFT to.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the minted token ID.

getSourcePublicationPointer

Returns the source publication of this collect NFT.

function getSourcePublicationPointer() external view returns (uint256, uint256);

Returns

NameTypeDescription
<none>uint256tuple First is the profile ID, and second is the publication ID.
<none>uint256

IERC721Burnable

Git Source

Author: Lens Protocol

Extension of ERC-721 including a function that allows the token to be burned.

Functions

burn

Burns an NFT, removing it from circulation and essentially destroying it.

function burn(uint256 tokenId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of the token to burn.

IERC721MetaTx

Git Source

Author: Lens Protocol

Extension of ERC-721 including meta-tx signatures related functions.

Functions

nonces

Returns the current signature nonce of the given signer.

function nonces(address signer) external view returns (uint256);

Parameters

NameTypeDescription
signeraddressThe address for which to query the nonce.

Returns

NameTypeDescription
<none>uint256uint256 The current nonce of the given signer.

getDomainSeparator

Returns the EIP-712 domain separator for this contract.

function getDomainSeparator() external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32bytes32 The domain separator.

IERC721Timestamped

Git Source

Author: Lens Protocol

Extension of ERC-721 including a struct for token data, which contains the owner and the mint timestamp, as well as their associated getters.

Functions

mintTimestampOf

Returns the mint timestamp associated with a given NFT.

function mintTimestampOf(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of the NFT to query the mint timestamp for.

Returns

NameTypeDescription
<none>uint256uint256 Mint timestamp, this is stored as a uint96 but returned as a uint256 to reduce unnecessary padding.

tokenDataOf

Returns the token data associated with a given NFT. This allows fetching the token owner and mint timestamp in a single call.

function tokenDataOf(uint256 tokenId) external view returns (Types.TokenData memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of the NFT to query the token data for.

Returns

NameTypeDescription
<none>Types.TokenDataTokenData A struct containing both the owner address and the mint timestamp.

exists

Returns whether a token with the given token ID exists.

function exists(uint256 tokenId) external view returns (bool);

Parameters

NameTypeDescription
tokenIduint256The token ID of the NFT to check existence for.

Returns

NameTypeDescription
<none>boolbool True if the token exists.

totalSupply

Returns the amount of tokens in circulation.

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The current total supply of tokens.

IFollowModule

Git Source

Author: Lens Protocol

This is the standard interface for all Lens-compatible Follow Modules. These are responsible for processing the follow actions and can be used to implement any kind of follow logic. For example:

  • Token-gated follows (e.g. a user must hold a certain amount of a token to follow a profile).
  • Paid follows (e.g. a user must pay a certain amount of a token to follow a profile).
  • Rewarding users for following a profile.
  • Etc.

Functions

initializeFollowModule

Initializes a follow module for a given Lens profile.

function initializeFollowModule(uint256 profileId, address transactionExecutor, bytes calldata data)
    external
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The Profile ID to initialize this follow module for.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).
databytesArbitrary data passed from the user to be decoded by the Follow Module during initialization.

Returns

NameTypeDescription
<none>bytesbytes The encoded data to be emitted from the hub.

processFollow

Processes a given follow.

function processFollow(
    uint256 followerProfileId,
    uint256 followTokenId,
    address transactionExecutor,
    uint256 targetProfileId,
    bytes calldata data
) external returns (bytes memory);

Parameters

NameTypeDescription
followerProfileIduint256The Profile ID of the follower's profile.
followTokenIduint256The Follow Token ID that is being used to follow. Zero if we are processing a new fresh follow, in this case, the follow ID assigned can be queried from the Follow NFT collection if needed.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).
targetProfileIduint256The token ID of the profile being followed.
databytesArbitrary data passed by the follower.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

IFollowNFT

Git Source

Author: Lens Protocol

This is the interface for the FollowNFT contract, which is cloned upon the first follow for any profile. By default the Follow tokens are tied to the follower profile, which means that they will be automatically transferred with it. This is achieved by them not being ERC-721 initially. However, the Follow NFT collections support converting them to ERC-721 tokens (i.e. wrapping) natively, enabling composability with existing ERC-721-based protocols.

Functions

initialize

Initializes the follow NFT.

Sets the targeted profile, and the token royalties.

function initialize(uint256 profileId) external;

Parameters

NameTypeDescription
profileIduint256The ID of the profile targeted by the follow tokens minted by this collection.

follow

Makes the passed profile follow the profile targeted in this contract.

function follow(uint256 followerProfileId, address transactionExecutor, uint256 followTokenId)
    external
    returns (uint256);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile acting as the follower.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).
followTokenIduint256The ID of the follow token to be used for this follow operation. Zero if a new follow token should be minted.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the token used to follow.

unfollow

Makes the passed profile unfollow the profile targeted in this contract.

function unfollow(uint256 unfollowerProfileId, address transactionExecutor) external;

Parameters

NameTypeDescription
unfollowerProfileIduint256The ID of the profile that is performing the unfollow operation.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).

removeFollower

Removes the follower from the given follow NFT.

Only on wrapped token.

function removeFollower(uint256 followTokenId) external;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to remove the follower from.

approveFollow

Approves the given profile to follow with the given wrapped token.

Only on wrapped tokens. It approves setting a follower on the given wrapped follow token, which lets the follow token owner to allow a profile to follow with his token without losing its ownership. This approval is cleared on transfers, as well as when unwrapping.

function approveFollow(uint256 approvedProfileId, uint256 followTokenId) external;

Parameters

NameTypeDescription
approvedProfileIduint256The ID of the profile approved to follow with the given token.
followTokenIduint256The ID of the follow token to be approved for the given profile.

wrap

Unties the follow token from the follower's profile one, and wraps it into the ERC-721 untied follow tokens collection. Untied follow tokens will NOT be automatically transferred with their follower profile.

Only on unwrapped follow tokens.

function wrap(uint256 followTokenId) external;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to untie and wrap.

wrap

Unties the follow token from the follower's profile one, and wraps it into the ERC-721 untied follow tokens collection. Untied follow tokens will NOT be automatically transferred with their follower profile.

Only on unwrapped follow tokens.

function wrap(uint256 followTokenId, address wrappedTokenReceiver) external;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to untie and wrap.
wrappedTokenReceiveraddressThe address where the follow token is minted to when being wrapped as ERC-721.

unwrap

Unwraps the follow token from the ERC-721 untied follow tokens collection, and ties it to the follower's profile token. Tokens that are tied to the follower profile will be automatically transferred with it.

function unwrap(uint256 followTokenId) external;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to unwrap and tie to its follower.

processBlock

Processes logic when the given profile is being blocked. If it was following the targeted profile, this will make it unfollow.

function processBlock(uint256 followerProfileId) external returns (bool);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the follow token to unwrap and tie.

Returns

NameTypeDescription
<none>boolbool True if the given profile was following and now has unfollowed, false otherwise.

getFollowerProfileId

GETTERS ///

Gets the ID of the profile following with the given follow token.

function getFollowerProfileId(uint256 followTokenId) external view returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose follower should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the profile following with the given token, zero if it is not being used to follow.

getOriginalFollowTimestamp

Gets the original follow timestamp of the given follow token.

function getOriginalFollowTimestamp(uint256 followTokenId) external view returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose original follow timestamp should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The timestamp of the first follow performed with the token, zero if was not used to follow yet.

getFollowTimestamp

Gets the current follow timestamp of the given follow token.

function getFollowTimestamp(uint256 followTokenId) external view returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose follow timestamp should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The timestamp of the current follow of the token, zero if it is not being used to follow.

getProfileIdAllowedToRecover

Gets the ID of the profile allowed to recover the given follow token.

function getProfileIdAllowedToRecover(uint256 followTokenId) external view returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose allowed profile to recover should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the profile allowed to recover the given follow token, zero if none of them is allowed.

getFollowData

Gets the follow data of the given follow token.

function getFollowData(uint256 followTokenId) external view returns (Types.FollowData memory);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose follow data should be queried.

Returns

NameTypeDescription
<none>Types.FollowDataFollowData The token data associated with the given follow token.

isFollowing

Tells if the given profile is following the profile targeted in this contract.

function isFollowing(uint256 followerProfileId) external view returns (bool);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile whose following state should be queried.

Returns

NameTypeDescription
<none>booluint256 The ID of the profile set as a follower in the given token, zero if it is not being used to follow.

getFollowTokenId

Gets the ID of the token being used to follow by the given follower.

function getFollowTokenId(uint256 followerProfileId) external view returns (uint256);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile whose follow ID should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the token being used to follow by the given follower, zero if he is not following.

getFollowApproved

Gets the ID of the profile approved to follow with the given token.

function getFollowApproved(uint256 followTokenId) external view returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the token whose approved to follow should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the profile approved to follow with the given token, zero if none of them is approved.

getFollowerCount

Gets the count of the followers of the profile targeted in this contract.

This number might be out of sync if one of the followers burns their profile.

function getFollowerCount() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The count of the followers of the profile targeted in this contract.

Errors

AlreadyFollowing

error AlreadyFollowing();

NotFollowing

error NotFollowing();

FollowTokenDoesNotExist

error FollowTokenDoesNotExist();

AlreadyWrapped

error AlreadyWrapped();

OnlyWrappedFollowTokens

error OnlyWrappedFollowTokens();

DoesNotHavePermissions

error DoesNotHavePermissions();

ILegacyCollectModule

Git Source

Author: Lens Protocol

This is the deprecated interface for previously Lens-compatible CollectModules.

Functions

initializePublicationCollectModule

Initializes data for a given publication being published. This can only be called by the hub.

function initializePublicationCollectModule(uint256 profileId, uint256 pubId, bytes calldata data)
    external
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
databytesArbitrary data passed from the user! to be decoded.

Returns

NameTypeDescription
<none>bytesbytes An ABI-encoded encapsulating the execution's state changes. This will be emitted by the hub alongside the collect module's address and should be consumed by front ends.

processCollect

Processes a collect action for a given publication, this can only be called by the hub.

function processCollect(
    uint256 referrerProfileId,
    address collector,
    uint256 profileId,
    uint256 pubId,
    bytes calldata data
) external;

Parameters

NameTypeDescription
referrerProfileIduint256The LensHub profile token ID of the referrer's profile (only different in case of mirrors).
collectoraddressThe collector address.
profileIduint256The token ID of the profile associated with the publication being collected.
pubIduint256The LensHub publication ID associated with the publication being collected.
databytesArbitrary data passed from the collector! to be decoded.

ILegacyCollectNFT

Git Source

Author: Lens Protocol

This is the interface for the Lens V1 CollectNFT contract. Which is cloned upon the first collect for any given publication.

Functions

initialize

Initializes the collect NFT, setting the feed as the privileged minter, storing the collected publication pointer and initializing the name and symbol in the LensNFTBase contract.

function initialize(uint256 profileId, uint256 pubId, string calldata name, string calldata symbol) external;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile in the hub that this Collect NFT points to.
pubIduint256The profile publication ID in the hub that this Collect NFT points to.
namestringThe name to set for this NFT.
symbolstringThe symbol to set for this NFT.

mint

Mints a collect NFT to the specified address.

function mint(address to) external returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the NFT to.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the minted token ID.

getSourcePublicationPointer

Returns the source publication of this collect NFT.

function getSourcePublicationPointer() external view returns (uint256, uint256);

Returns

NameTypeDescription
<none>uint256tuple First is the profile ID, and second is the publication ID.
<none>uint256

ILegacyFollowModule

Git Source

Author: Lens Protocol

This is the deprecated interface for previously Lens-compatible FollowModules.

Functions

initializeFollowModule

Initializes a follow module for a given Lens profile. This can only be called by the hub contract.

function initializeFollowModule(uint256 profileId, bytes calldata data) external returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to initialize this follow module for.
databytesArbitrary data passed by the profile creator.

Returns

NameTypeDescription
<none>bytesbytes The encoded data to emit in the hub.

processFollow

Processes a given follow, this can only be called from the LensHub contract.

function processFollow(address follower, uint256 profileId, bytes calldata data) external;

Parameters

NameTypeDescription
followeraddressThe follower address.
profileIduint256The token ID of the profile being followed.
databytesArbitrary data passed by the follower.

followModuleTransferHook

This is a transfer hook that is called upon follow NFT transfer in `beforeTokenTransfer. This can only be called from the LensHub contract. NOTE: Special care needs to be taken here: It is possible that follow NFTs were issued before this module was initialized if the profile's follow module was previously different. This transfer hook should take this into consideration, especially when the module holds a state associated with individual follow NFTs.

function followModuleTransferHook(uint256 profileId, address from, address to, uint256 followNFTTokenId) external;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile associated with the follow NFT being transferred.
fromaddressThe address sending the follow NFT.
toaddressThe address receiving the follow NFT.
followNFTTokenIduint256The token ID of the follow NFT being transferred.

isFollowing

This is a helper function that could be used in conjunction with specific collect modules. NOTE: This function IS meant to replace a check on follower NFT ownership. NOTE: It is assumed that not all collect modules are aware of the token ID to pass. In these cases, this should receive a followNFTTokenId of 0, which is impossible regardless. One example of a use case for this would be a subscription-based following system:

  1. The collect module:
  • Decodes a follower NFT token ID from user-passed data.
  • Fetches the follow module from the hub.
  • Calls isFollowing passing the profile ID, follower & follower token ID and checks it returned true.
  1. The follow module:
  • Validates the subscription status for that given NFT, reverting on an invalid subscription.
function isFollowing(uint256 profileId, address follower, uint256 followNFTTokenId) external view returns (bool);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to validate the follow for.
followeraddressThe follower address to validate the follow for.
followNFTTokenIduint256The followNFT token ID to validate the follow for.

Returns

NameTypeDescription
<none>booltrue if the given address is following the given profile ID, false otherwise.

ILegacyReferenceModule

Git Source

Author: Lens Protocol

This is the deprecated interface for previously Lens-compatible ReferenceModules.

Functions

initializeReferenceModule

Initializes data for a given publication being published. This can only be called by the hub.

function initializeReferenceModule(uint256 profileId, uint256 pubId, bytes calldata data)
    external
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
databytesArbitrary data passed from the user to be decoded.

Returns

NameTypeDescription
<none>bytesbytes An ABI-encoded data encapsulating the execution's state changes. This will be emitted by the hub alongside the collect module's address and should be consumed by front ends.

processComment

Processes a comment action referencing a given publication. This can only be called by the hub.

function processComment(uint256 profileId, uint256 pointedProfileId, uint256 pointedPubId, bytes calldata data)
    external;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile associated with the publication being published.
pointedProfileIduint256The profile ID of the profile associated with the publication being referenced.
pointedPubIduint256The publication ID of the publication being referenced.
databytesArbitrary data passed from the commenter! to be decoded.

processMirror

Processes a mirror action referencing a given publication. This can only be called by the hub.

function processMirror(uint256 profileId, uint256 pointedProfileId, uint256 pointedPubId, bytes calldata data)
    external;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile associated with the publication being published.
pointedProfileIduint256The profile ID of the profile associated with the publication being referenced.
pointedPubIduint256The publication ID of the publication being referenced.
databytesArbitrary data passed from the mirrorer! to be decoded.

ILensERC721

Git Source

Inherits: IERC721, IERC721Timestamped, IERC721Burnable, IERC721MetaTx, IERC721Metadata

ILensGovernable

Git Source

Author: Lens Protocol

This is the interface for the Lens Protocol main governance functions.

Functions

setGovernance

Sets the privileged governance role.

function setGovernance(address newGovernance) external;

Parameters

NameTypeDescription
newGovernanceaddressThe new governance address to set.

setEmergencyAdmin

Sets the emergency admin, which is a permissioned role able to set the protocol state.

function setEmergencyAdmin(address newEmergencyAdmin) external;

Parameters

NameTypeDescription
newEmergencyAdminaddressThe new emergency admin address to set.

setState

Sets the protocol state to either a global pause, a publishing pause or an unpaused state.

function setState(Types.ProtocolState newState) external;

Parameters

NameTypeDescription
newStateTypes.ProtocolStateThe state to set. It can be one of the following: - Unpaused: The protocol is fully operational. - PublishingPaused: The protocol is paused for publishing, but it is still operational for others operations. - Paused: The protocol is paused for all operations.

whitelistProfileCreator

Adds or removes a profile creator from the whitelist.

function whitelistProfileCreator(address profileCreator, bool whitelist) external;

Parameters

NameTypeDescription
profileCreatoraddressThe profile creator address to add or remove from the whitelist.
whitelistboolWhether or not the profile creator should be whitelisted.

setTreasury

Sets the treasury address.

function setTreasury(address newTreasury) external;

Parameters

NameTypeDescription
newTreasuryaddressThe new treasury address to set.

setTreasuryFee

Sets the treasury fee.

function setTreasuryFee(uint16 newTreasuryFee) external;

Parameters

NameTypeDescription
newTreasuryFeeuint16The new treasury fee to set.

getGovernance

Returns the currently configured governance address.

function getGovernance() external view returns (address);

Returns

NameTypeDescription
<none>addressaddress The address of the currently configured governance.

getState

Gets the state currently set in the protocol. It could be a global pause, a publishing pause or an unpaused state.

function getState() external view returns (Types.ProtocolState);

Returns

NameTypeDescription
<none>Types.ProtocolStateTypes.ProtocolState The state currently set in the protocol.

isProfileCreatorWhitelisted

Returns whether or not a profile creator is whitelisted.

function isProfileCreatorWhitelisted(address profileCreator) external view returns (bool);

Parameters

NameTypeDescription
profileCreatoraddressThe address of the profile creator to check.

Returns

NameTypeDescription
<none>boolbool True if the profile creator is whitelisted, false otherwise.

getTreasury

Returns the treasury address.

function getTreasury() external view returns (address);

Returns

NameTypeDescription
<none>addressaddress The treasury address.

getTreasuryFee

Returns the treasury fee.

function getTreasuryFee() external view returns (uint16);

Returns

NameTypeDescription
<none>uint16uint16 The treasury fee.

getTreasuryData

Returns the treasury address and treasury fee in a single call.

function getTreasuryData() external view returns (address, uint16);

Returns

NameTypeDescription
<none>addresstuple First, the treasury address, second, the treasury fee.
<none>uint16

ILensHandles

Git Source

Inherits: IERC721

Author: Lens Protocol

This is the interface for the LensHandles contract that is responsible for minting and burning handle NFTs. A handle is composed of a local name and a namespace, separated by a dot. Example: satoshi.lens is a handle composed of the local name satoshi and the namespace lens.

Functions

mintHandle

Mints a handle NFT in the given namespace.

function mintHandle(address to, string calldata localName) external returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the handle to.
localNamestringThe local name of the handle (the part before ".lens").

Returns

NameTypeDescription
<none>uint256uint256 The ID of the handle NFT minted.

burn

Burns a handle NFT.

function burn(uint256 tokenId) external;

Parameters

NameTypeDescription
tokenIduint256The ID of the handle NFT to burn.

getNamespace

Gets the namespace of the contract. It's 'lens' for the LensHandles contract.

function getNamespace() external pure returns (string memory);

Returns

NameTypeDescription
<none>stringstring The namespace of the contract.

getNamespaceHash

Gets the hash of the namespace of the contract. It's keccak256('lens') for the LensHandles contract.

function getNamespaceHash() external pure returns (bytes32);

Returns

NameTypeDescription
<none>bytes32bytes32 The hash of the namespace of the contract.

exists

Returns whether tokenId exists. Tokens start existing when they are minted (_mint), and stop existing when they are burned (_burn).

function exists(uint256 tokenId) external view returns (bool);

Returns

NameTypeDescription
<none>boolbool Whether the token exists.

ILensHub

Git Source

Inherits: ILensProfiles, ILensProtocol, ILensGovernable, ILensHubEventHooks, ILensImplGetters

ILensHubEventHooks

Git Source

Author: Lens Protocol

This is the interface for the LensHub contract's event hooks. As we want most of the core events to be emitted by the LensHub contract, event hooks are needed for core events generated by pheripheral contracts.

Functions

emitUnfollowedEvent

Helper function to emit an Unfollowed event from the hub, to be consumed by indexers to track unfollows.

function emitUnfollowedEvent(uint256 unfollowerProfileId, uint256 idOfProfileUnfollowed, address transactionExecutor)
    external;

Parameters

NameTypeDescription
unfollowerProfileIduint256The ID of the profile that executed the unfollow.
idOfProfileUnfolloweduint256The ID of the profile that was unfollowed.
transactionExecutoraddressThe address of the account executing the unfollow operation.

ILensHubInitializable

Git Source

Author: Lens Protocol

This is the interface for the LensHub contract, the main entry point for the Lens Protocol. You'll find all the events and external functions, as well as the reasoning behind them here.

Functions

initialize

Initializes the LensHub, setting the initial governance address, the name and symbol of the profiles in the LensNFTBase contract, and Protocol State (Paused).

This is assuming a proxy pattern is implemented.

function initialize(string calldata name, string calldata symbol, address newGovernance) external;

Parameters

NameTypeDescription
namestringThe name of the Profile NFT.
symbolstringThe symbol of the Profile NFT.
newGovernanceaddressThe governance address to set.

ILensImplGetters

Git Source

Author: Lens Protocol

This is the interface for the LensHub contract's implementation getters. These implementations will be used for deploying each respective contract for each profile.

Functions

getFollowNFTImpl

Returns the Follow NFT implementation address that is used for all deployed Follow NFTs.

function getFollowNFTImpl() external view returns (address);

Returns

NameTypeDescription
<none>addressaddress The Follow NFT implementation address.

getLegacyCollectNFTImpl

Returns the Collect NFT implementation address that is used for each new deployed Collect NFT.

function getLegacyCollectNFTImpl() external view returns (address);

Returns

NameTypeDescription
<none>addressaddress The Collect NFT implementation address.

getModuleRegistry

Returns the address of the registry that stores all modules that are used by the Lens Protocol.

function getModuleRegistry() external view returns (address);

Returns

NameTypeDescription
<none>addressaddress The address of the Module Registry contract.

ILensProfiles

Git Source

Inherits: ILensERC721

Functions

DANGER__disableTokenGuardian

DANGER: Triggers disabling the profile protection mechanism for the msg.sender, which will allow transfers or approvals over profiles held by it. Disabling the mechanism will have a 7-day timelock before it becomes effective, allowing the owner to re-enable the protection back in case of being under attack. The protection layer only applies to EOA wallets.

function DANGER__disableTokenGuardian() external;

enableTokenGuardian

Enables back the profile protection mechanism for the msg.sender, preventing profile transfers or approvals (except when revoking them). The protection layer only applies to EOA wallets.

function enableTokenGuardian() external;

getTokenGuardianDisablingTimestamp

Returns the timestamp at which the Token Guardian will become effectively disabled.

function getTokenGuardianDisablingTimestamp(address wallet) external view returns (uint256);

Parameters

NameTypeDescription
walletaddressThe address to check the timestamp for.

Returns

NameTypeDescription
<none>uint256uint256 The timestamp at which the Token Guardian will become effectively disabled. Zero if enabled.

ILensProtocol

Git Source

Author: Lens Protocol

This is the interface for Lens Protocol's core functions. It contains all the entry points for performing social operations.

Functions

createProfile

Creates a profile with the specified parameters, minting a Profile NFT to the given recipient.

function createProfile(Types.CreateProfileParams calldata createProfileParams) external returns (uint256);

Parameters

NameTypeDescription
createProfileParamsTypes.CreateProfileParamsA CreateProfileParams struct containing the needed params.

setProfileMetadataURI

Sets the metadata URI for the given profile.

function setProfileMetadataURI(uint256 profileId, string calldata metadataURI) external;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to set the metadata URI for.
metadataURIstringThe metadata URI to set for the given profile.

setProfileMetadataURIWithSig

function setProfileMetadataURIWithSig(
    uint256 profileId,
    string calldata metadataURI,
    Types.EIP712Signature calldata signature
) external;

setFollowModule

Sets the follow module for the given profile.

function setFollowModule(uint256 profileId, address followModule, bytes calldata followModuleInitData) external;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to set the follow module for.
followModuleaddressThe follow module to set for the given profile, must be whitelisted.
followModuleInitDatabytesThe data to be passed to the follow module for initialization.

setFollowModuleWithSig

function setFollowModuleWithSig(
    uint256 profileId,
    address followModule,
    bytes calldata followModuleInitData,
    Types.EIP712Signature calldata signature
) external;

changeDelegatedExecutorsConfig

Changes the delegated executors configuration for the given profile. It allows setting the approvals for delegated executors in the specified configuration, as well as switching to it.

function changeDelegatedExecutorsConfig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals,
    uint64 configNumber,
    bool switchToGivenConfig
) external;

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile to which the delegated executor is being changed for.
delegatedExecutorsaddress[]The array of delegated executors to set the approval for.
approvalsbool[]The array of booleans indicating the corresponding executor's new approval status.
configNumberuint64The number of the configuration where the executor approval state is being set.
switchToGivenConfigboolA boolean indicating if the configuration must be switched to the one with the given number.

changeDelegatedExecutorsConfig

Changes the delegated executors configuration for the given profile under the current configuration.

function changeDelegatedExecutorsConfig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals
) external;

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile to which the delegated executor is being changed for.
delegatedExecutorsaddress[]The array of delegated executors to set the approval for.
approvalsbool[]The array of booleans indicating the corresponding executor's new approval status.

changeDelegatedExecutorsConfigWithSig

function changeDelegatedExecutorsConfigWithSig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals,
    uint64 configNumber,
    bool switchToGivenConfig,
    Types.EIP712Signature calldata signature
) external;

post

Publishes a post. Post is the most basic publication type, and can be used to publish any kind of content. Posts can have these types of modules initialized:

  • Action modules: any number of publication actions (e.g. collect, tip, etc.)
  • Reference module: a module handling the rules when referencing this post (e.g. token-gated comments)
function post(Types.PostParams calldata postParams) external returns (uint256);

Parameters

NameTypeDescription
postParamsTypes.PostParamsA PostParams struct containing the needed parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the post's publication ID.

postWithSig

function postWithSig(Types.PostParams calldata postParams, Types.EIP712Signature calldata signature)
    external
    returns (uint256);

comment

Publishes a comment on the given publication. Comment is a type of reference publication that points to another publication. Comments can have these types of modules initialized:

  • Action modules: any number of publication actions (e.g. collect, tip, etc.)
  • Reference module: a module handling the rules when referencing this comment (e.g. token-gated mirrors) Comments can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).
function comment(Types.CommentParams calldata commentParams) external returns (uint256);

Parameters

NameTypeDescription
commentParamsTypes.CommentParamsA CommentParams struct containing the needed parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the comment's publication ID.

commentWithSig

function commentWithSig(Types.CommentParams calldata commentParams, Types.EIP712Signature calldata signature)
    external
    returns (uint256);

mirror

Publishes a mirror of the given publication. Mirror is a type of reference publication that points to another publication but doesn't have content. Mirrors don't have any modules initialized. Mirrors can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). You cannot mirror a mirror, comment on a mirror, or quote a mirror.

function mirror(Types.MirrorParams calldata mirrorParams) external returns (uint256);

Parameters

NameTypeDescription
mirrorParamsTypes.MirrorParamsA MirrorParams struct containing the necessary parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the mirror's publication ID.

mirrorWithSig

function mirrorWithSig(Types.MirrorParams calldata mirrorParams, Types.EIP712Signature calldata signature)
    external
    returns (uint256);

quote

Publishes a quote of the given publication. Quote is a type of reference publication similar to mirror, but it has content and modules. Quotes can have these types of modules initialized:

  • Action modules: any number of publication actions (e.g. collect, tip, etc.)
  • Reference module: a module handling the rules when referencing this quote (e.g. token-gated comments on quote) Quotes can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). Unlike mirrors, you can mirror a quote, comment on a quote, or quote a quote.
function quote(Types.QuoteParams calldata quoteParams) external returns (uint256);

Parameters

NameTypeDescription
quoteParamsTypes.QuoteParamsA QuoteParams struct containing the needed parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the quote's publication ID.

quoteWithSig

function quoteWithSig(Types.QuoteParams calldata quoteParams, Types.EIP712Signature calldata signature)
    external
    returns (uint256);

follow

Follows given profiles, executing each profile's follow module logic (if any).

Both the idsOfProfilesToFollow, followTokenIds, and datas arrays must be of the same length, regardless if the profiles do not have a follow module set.

function follow(
    uint256 followerProfileId,
    uint256[] calldata idsOfProfilesToFollow,
    uint256[] calldata followTokenIds,
    bytes[] calldata datas
) external returns (uint256[] memory);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile the follows are being executed for.
idsOfProfilesToFollowuint256[]The array of IDs of profiles to follow.
followTokenIdsuint256[]The array of follow token IDs to use for each follow (0 if you don't own a follow token).
datasbytes[]The arbitrary data array to pass to the follow module for each profile if needed.

Returns

NameTypeDescription
<none>uint256[]uint256[] An array of follow token IDs representing the follow tokens created for each follow.

followWithSig

function followWithSig(
    uint256 followerProfileId,
    uint256[] calldata idsOfProfilesToFollow,
    uint256[] calldata followTokenIds,
    bytes[] calldata datas,
    Types.EIP712Signature calldata signature
) external returns (uint256[] memory);

unfollow

Unfollows given profiles.

function unfollow(uint256 unfollowerProfileId, uint256[] calldata idsOfProfilesToUnfollow) external;

Parameters

NameTypeDescription
unfollowerProfileIduint256The ID of the profile the unfollows are being executed for.
idsOfProfilesToUnfollowuint256[]The array of IDs of profiles to unfollow.

unfollowWithSig

function unfollowWithSig(
    uint256 unfollowerProfileId,
    uint256[] calldata idsOfProfilesToUnfollow,
    Types.EIP712Signature calldata signature
) external;

setBlockStatus

Sets the block status for the given profiles. Changing a profile's block status to true (i.e. blocked), when will also force them to unfollow. Blocked profiles cannot perform any actions with the profile that blocked them: they cannot comment or mirror their publications, they cannot follow them, they cannot collect, tip them, etc.

Both the idsOfProfilesToSetBlockStatus and blockStatus arrays must be of the same length.

function setBlockStatus(
    uint256 byProfileId,
    uint256[] calldata idsOfProfilesToSetBlockStatus,
    bool[] calldata blockStatus
) external;

Parameters

NameTypeDescription
byProfileIduint256The ID of the profile that is blocking/unblocking somebody.
idsOfProfilesToSetBlockStatusuint256[]The array of IDs of profiles to set block status.
blockStatusbool[]The array of block statuses to use for each (true is blocked).

setBlockStatusWithSig

function setBlockStatusWithSig(
    uint256 byProfileId,
    uint256[] calldata idsOfProfilesToSetBlockStatus,
    bool[] calldata blockStatus,
    Types.EIP712Signature calldata signature
) external;

collectLegacy

Collects a given publication via signature with the specified parameters. Collect can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).

function collectLegacy(Types.LegacyCollectParams calldata collectParams) external returns (uint256);

Parameters

NameTypeDescription
collectParamsTypes.LegacyCollectParamsA CollectParams struct containing the parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the minted token ID.

collectLegacyWithSig

function collectLegacyWithSig(
    Types.LegacyCollectParams calldata collectParams,
    Types.EIP712Signature calldata signature
) external returns (uint256);

act

Acts on a given publication with the specified parameters. You can act on a publication except a mirror (if it has at least one action module initialized). Actions can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).

function act(Types.PublicationActionParams calldata publicationActionParams) external returns (bytes memory);

Parameters

NameTypeDescription
publicationActionParamsTypes.PublicationActionParamsA PublicationActionParams struct containing the parameters.

Returns

NameTypeDescription
<none>bytesbytes Arbitrary data the action module returns.

actWithSig

function actWithSig(
    Types.PublicationActionParams calldata publicationActionParams,
    Types.EIP712Signature calldata signature
) external returns (bytes memory);

isFollowing

VIEW FUNCTIONS ///

Returns whether or not followerProfileId is following followedProfileId.

function isFollowing(uint256 followerProfileId, uint256 followedProfileId) external view returns (bool);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile whose following state should be queried.
followedProfileIduint256The ID of the profile whose followed state should be queried.

Returns

NameTypeDescription
<none>boolbool True if followerProfileId is following followedProfileId, false otherwise.

isDelegatedExecutorApproved

Returns whether the given address is approved as delegated executor, in the configuration with the given number, to act on behalf of the given profile.

function isDelegatedExecutorApproved(uint256 delegatorProfileId, address delegatedExecutor, uint64 configNumber)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile to check the delegated executor approval for.
delegatedExecutoraddressThe address to query the delegated executor approval for.
configNumberuint64The number of the configuration where the executor approval state is being queried.

Returns

NameTypeDescription
<none>boolbool True if the address is approved as a delegated executor to act on behalf of the profile in the given configuration, false otherwise.

isDelegatedExecutorApproved

Returns whether the given address is approved as delegated executor, in the current configuration, to act on behalf of the given profile.

function isDelegatedExecutorApproved(uint256 delegatorProfileId, address delegatedExecutor)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile to check the delegated executor approval for.
delegatedExecutoraddressThe address to query the delegated executor approval for.

Returns

NameTypeDescription
<none>boolbool True if the address is approved as a delegated executor to act on behalf of the profile in the current configuration, false otherwise.

getDelegatedExecutorsConfigNumber

Returns the current delegated executor config number for the given profile.

function getDelegatedExecutorsConfigNumber(uint256 delegatorProfileId) external view returns (uint64);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile from which the delegated executors config number is being queried

Returns

NameTypeDescription
<none>uint64uint256 The current delegated executor configuration number.

getDelegatedExecutorsPrevConfigNumber

Returns the previous used delegated executor config number for the given profile.

function getDelegatedExecutorsPrevConfigNumber(uint256 delegatorProfileId) external view returns (uint64);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile from which the delegated executors' previous configuration number set is being queried.

Returns

NameTypeDescription
<none>uint64uint256 The delegated executor configuration number previously set. It will coincide with the current configuration set if it was never switched from the default one.

getDelegatedExecutorsMaxConfigNumberSet

Returns the maximum delegated executor config number for the given profile. This is the maximum config number that was ever used by this profile. When creating a new clean configuration, you can only use a number that is maxConfigNumber + 1.

function getDelegatedExecutorsMaxConfigNumberSet(uint256 delegatorProfileId) external view returns (uint64);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile from which the delegated executors' maximum configuration number set is being queried.

Returns

NameTypeDescription
<none>uint64uint256 The delegated executor maximum configuration number set.

isBlocked

Returns whether profileId is blocked by byProfileId. See setBlockStatus() for more information on how blocking works on the platform.

function isBlocked(uint256 profileId, uint256 byProfileId) external view returns (bool);

Parameters

NameTypeDescription
profileIduint256The ID of the profile whose blocked status should be queried.
byProfileIduint256The ID of the profile whose blocker status should be queried.

Returns

NameTypeDescription
<none>boolbool True if profileId is blocked by byProfileId, false otherwise.

getContentURI

Returns the URI associated with a given publication. This is used to store the publication's metadata, e.g.: content, images, etc.

function getContentURI(uint256 profileId, uint256 pubId) external view returns (string memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>stringstring The URI associated with a given publication.

getProfile

Returns the full profile struct associated with a given profile token ID.

function getProfile(uint256 profileId) external view returns (Types.Profile memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to query.

Returns

NameTypeDescription
<none>Types.ProfileProfile The profile struct of the given profile.

getPublication

Returns the full publication struct for a given publication.

function getPublication(uint256 profileId, uint256 pubId) external view returns (Types.PublicationMemory memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>Types.PublicationMemoryPublication The publication struct associated with the queried publication.

getPublicationType

Returns the type of a given publication. The type can be one of the following (see PublicationType enum):

  • Nonexistent
  • Post
  • Comment
  • Mirror
  • Quote
function getPublicationType(uint256 profileId, uint256 pubId) external view returns (Types.PublicationType);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>Types.PublicationTypePublicationType The publication type of the queried publication.

isActionModuleEnabledInPublication

Returns wether a given Action Module is enabled for a given publication.

function isActionModuleEnabledInPublication(uint256 profileId, uint256 pubId, address module)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.
moduleaddressThe address of the Action Module to query.

Returns

NameTypeDescription
<none>boolbool True if the Action Module is enabled for the queried publication, false if not.

IModuleRegistry

Git Source

Functions

registerModule

function registerModule(address moduleAddress, uint256 moduleType) external returns (bool);

getModuleTypes

function getModuleTypes(address moduleAddress) external view returns (uint256);

isModuleRegistered

function isModuleRegistered(address moduleAddress) external view returns (bool);

isModuleRegisteredAs

function isModuleRegisteredAs(address moduleAddress, uint256 moduleType) external view returns (bool);

registerErc20Currency

function registerErc20Currency(address currencyAddress) external returns (bool);

isErc20CurrencyRegistered

function isErc20CurrencyRegistered(address currencyAddress) external view returns (bool);

Enums

ModuleType

enum ModuleType {
    __,
    PUBLICATION_ACTION_MODULE,
    REFERENCE_MODULE,
    FOLLOW_MODULE
}

IPublicationActionModule

Git Source

Author: Lens Protocol

This is the standard interface for all Lens-compatible Publication Actions. Publication action modules allow users to execute actions directly from a publication, like:

  • Minting NFTs.
  • Collecting a publication.
  • Sending funds to the publication author (e.g. tipping).
  • Etc. Referrers are supported, so any publication or profile that references the publication can receive a share from the publication's action if the action module supports it.

Functions

initializePublicationAction

Initializes the action module for the given publication being published with this Action module.

function initializePublicationAction(uint256 profileId, uint256 pubId, address transactionExecutor, bytes calldata data)
    external
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The profile ID of the author publishing the content with this Publication Action.
pubIduint256The publication ID being published.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).
databytesArbitrary data passed from the user to be decoded by the Action Module during initialization.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processPublicationAction

Processes the action for a given publication. This includes the action's logic and any monetary/token operations.

function processPublicationAction(Types.ProcessActionParams calldata processActionParams)
    external
    returns (bytes memory);

Parameters

NameTypeDescription
processActionParamsTypes.ProcessActionParamsThe parameters needed to execute the publication action.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

IReferenceModule

Git Source

Author: Lens Protocol

This is the standard interface for all Lens-compatible ReferenceModules. Reference modules allow executing some action when a publication is referenced, like:

  • Rewards for mirroring/commenting/quoting a publication.
  • Token-gated comments/mirrors/quotes of a publication.
  • Etc.

Functions

initializeReferenceModule

Initializes data for the given publication being published with this Reference module.

function initializeReferenceModule(uint256 profileId, uint256 pubId, address transactionExecutor, bytes calldata data)
    external
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).
databytesArbitrary data passed from the user to be decoded by the Reference Module during initialization.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processComment

Processes a comment being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

function processComment(Types.ProcessCommentParams calldata processCommentParams) external returns (bytes memory);

Parameters

NameTypeDescription
processCommentParamsTypes.ProcessCommentParamsThe parameters for processing a comment.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processQuote

Processes a quote being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

function processQuote(Types.ProcessQuoteParams calldata processQuoteParams) external returns (bytes memory);

Parameters

NameTypeDescription
processQuoteParamsTypes.ProcessQuoteParamsThe parameters for processing a quote.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processMirror

Processes a mirror being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

function processMirror(Types.ProcessMirrorParams calldata processMirrorParams) external returns (bytes memory);

Parameters

NameTypeDescription
processMirrorParamsTypes.ProcessMirrorParamsThe parameters for processing a mirror.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

ITokenHandleRegistry

Git Source

Author: Lens Protocol

The interface for TokenHandleRegistry contract that is responsible for linking a handle NFT to a token NFT. Linking means a connection between the two NFTs is created, and the handle NFT can be used to resolve the token NFT or vice versa. The registry is responsible for keeping track of the links between the NFTs, and for resolving them. The first version of the registry is hard-coded to support only the .lens namespace and the Lens Protocol Profiles.

Functions

Lens V1 -> V2 migration function. Links a handle NFT to a profile NFT without additional checks to save gas. Will be called by the migration function (in MigrationLib) in LensHub, only for new handles being migrated.

function migrationLink(uint256 handleId, uint256 profileId) external;

Parameters

NameTypeDescription
handleIduint256ID of the .lens namespace handle NFT
profileIduint256ID of the Lens Protocol Profile NFT

Links a handle NFT with a profile NFT. Linking means a connection between the two NFTs is created, and the handle NFT can be used to resolve the profile NFT or vice versa.

*In the first version of the registry, the NFT contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one accepting addresses of the handle and token contracts.*
function link(uint256 handleId, uint256 profileId) external;

Parameters

NameTypeDescription
handleIduint256ID of the .lens namespace handle NFT
profileIduint256ID of the Lens Protocol Profile NFT

Unlinks a handle NFT from a profile NFT.

*In the first version of the registry, the contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one accepting addresses of the handle and token contracts.*
function unlink(uint256 handleId, uint256 profileId) external;

Parameters

NameTypeDescription
handleIduint256ID of the .lens namespace handle NFT
profileIduint256ID of the Lens Protocol Profile NFT

resolve

Resolves a handle NFT to a profile NFT.

*In the first version of the registry, the contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one.*
function resolve(uint256 handleId) external view returns (uint256);

Parameters

NameTypeDescription
handleIduint256ID of the .lens namespace handle NFT

Returns

NameTypeDescription
<none>uint256tokenId ID of the Lens Protocol Profile NFT

getDefaultHandle

Gets a default handle for a profile NFT (aka reverse resolution).

*In the first version of the registry, the contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one.*
function getDefaultHandle(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256ID of the Lens Protocol Profile NFT

Returns

NameTypeDescription
<none>uint256handleId ID of the .lens namespace handle NFT

Contents

Contents

Errors

Git Source

Errors

CannotInitImplementation

error CannotInitImplementation();

Initialized

error Initialized();

SignatureExpired

error SignatureExpired();

SignatureInvalid

error SignatureInvalid();

InvalidOwner

error InvalidOwner();

NotOwnerOrApproved

error NotOwnerOrApproved();

NotHub

error NotHub();

TokenDoesNotExist

error TokenDoesNotExist();

NotGovernance

error NotGovernance();

NotGovernanceOrEmergencyAdmin

error NotGovernanceOrEmergencyAdmin();

EmergencyAdminCanOnlyPauseFurther

error EmergencyAdminCanOnlyPauseFurther();

NotProfileOwner

error NotProfileOwner();

PublicationDoesNotExist

error PublicationDoesNotExist();

CallerNotFollowNFT

error CallerNotFollowNFT();

CallerNotCollectNFT

error CallerNotCollectNFT();

ArrayMismatch

error ArrayMismatch();

NotWhitelisted

error NotWhitelisted();

NotRegistered

error NotRegistered();

InvalidParameter

error InvalidParameter();

ExecutorInvalid

error ExecutorInvalid();

Blocked

error Blocked();

SelfBlock

error SelfBlock();

NotFollowing

error NotFollowing();

SelfFollow

error SelfFollow();

InvalidReferrer

error InvalidReferrer();

InvalidPointedPub

error InvalidPointedPub();

NonERC721ReceiverImplementer

error NonERC721ReceiverImplementer();

AlreadyEnabled

error AlreadyEnabled();

InitParamsInvalid

error InitParamsInvalid();

ActionNotAllowed

error ActionNotAllowed();

CollectNotAllowed

error CollectNotAllowed();

Paused

error Paused();

PublishingPaused

error PublishingPaused();

GuardianEnabled

error GuardianEnabled();

NotEOA

error NotEOA();

DisablingAlreadyTriggered

error DisablingAlreadyTriggered();

NotMigrationAdmin

error NotMigrationAdmin();

Events

Git Source

Events

BaseInitialized

Emitted when the NFT contract's name and symbol are set at initialization.

event BaseInitialized(string name, string symbol, uint256 timestamp);

StateSet

Emitted when the hub state is set.

event StateSet(
    address indexed caller,
    Types.ProtocolState indexed prevState,
    Types.ProtocolState indexed newState,
    uint256 timestamp
);

GovernanceSet

Emitted when the governance address is changed. We emit the caller even though it should be the previous governance address, as we cannot guarantee this will always be the case due to upgradeability.

event GovernanceSet(
    address indexed caller, address indexed prevGovernance, address indexed newGovernance, uint256 timestamp
);

EmergencyAdminSet

Emitted when the emergency admin is changed. We emit the caller even though it should be the previous governance address, as we cannot guarantee this will always be the case due to upgradeability.

event EmergencyAdminSet(
    address indexed caller, address indexed oldEmergencyAdmin, address indexed newEmergencyAdmin, uint256 timestamp
);

ProfileCreatorWhitelisted

Emitted when a profile creator is added to or removed from the whitelist.

event ProfileCreatorWhitelisted(address indexed profileCreator, bool indexed whitelisted, uint256 timestamp);

ProfileCreated

Emitted when a profile is created.

event ProfileCreated(uint256 indexed profileId, address indexed creator, address indexed to, uint256 timestamp);

DelegatedExecutorsConfigChanged

Emitted when a delegated executors configuration is changed.

event DelegatedExecutorsConfigChanged(
    uint256 indexed delegatorProfileId,
    uint256 indexed configNumber,
    address[] delegatedExecutors,
    bool[] approvals,
    uint256 timestamp
);

DelegatedExecutorsConfigApplied

Emitted when a delegated executors configuration is applied.

event DelegatedExecutorsConfigApplied(
    uint256 indexed delegatorProfileId, uint256 indexed configNumber, uint256 timestamp
);

FollowModuleSet

Emitted when a profile's follow module is set.

event FollowModuleSet(
    uint256 indexed profileId,
    address followModule,
    bytes followModuleReturnData,
    address transactionExecutor,
    uint256 timestamp
);

PostCreated

Emitted when a post is successfully published.

event PostCreated(
    Types.PostParams postParams,
    uint256 indexed pubId,
    bytes[] actionModulesInitReturnDatas,
    bytes referenceModuleInitReturnData,
    address transactionExecutor,
    uint256 timestamp
);

CommentCreated

Emitted when a comment is successfully published.

event CommentCreated(
    Types.CommentParams commentParams,
    uint256 indexed pubId,
    bytes referenceModuleReturnData,
    bytes[] actionModulesInitReturnDatas,
    bytes referenceModuleInitReturnData,
    address transactionExecutor,
    uint256 timestamp
);

MirrorCreated

Emitted when a mirror is successfully published.

event MirrorCreated(
    Types.MirrorParams mirrorParams,
    uint256 indexed pubId,
    bytes referenceModuleReturnData,
    address transactionExecutor,
    uint256 timestamp
);

QuoteCreated

Emitted when a quote is successfully published.

event QuoteCreated(
    Types.QuoteParams quoteParams,
    uint256 indexed pubId,
    bytes referenceModuleReturnData,
    bytes[] actionModulesInitReturnDatas,
    bytes referenceModuleInitReturnData,
    address transactionExecutor,
    uint256 timestamp
);

FollowNFTDeployed

Emitted when a followNFT clone is deployed using a lazy deployment pattern.

event FollowNFTDeployed(uint256 indexed profileId, address indexed followNFT, uint256 timestamp);

LegacyCollectNFTDeployed

Emitted when a collectNFT clone is deployed using a lazy deployment pattern.

event LegacyCollectNFTDeployed(
    uint256 indexed profileId, uint256 indexed pubId, address indexed collectNFT, uint256 timestamp
);

Acted

Emitted upon a successful action.

event Acted(
    Types.PublicationActionParams publicationActionParams,
    bytes actionModuleReturnData,
    address transactionExecutor,
    uint256 timestamp
);

Followed

Emitted upon a successful follow operation.

event Followed(
    uint256 indexed followerProfileId,
    uint256 idOfProfileFollowed,
    uint256 followTokenIdAssigned,
    bytes followModuleData,
    bytes processFollowModuleReturnData,
    address transactionExecutor,
    uint256 timestamp
);

Unfollowed

Emitted upon a successful unfollow operation.

event Unfollowed(
    uint256 indexed unfollowerProfileId, uint256 idOfProfileUnfollowed, address transactionExecutor, uint256 timestamp
);

Blocked

Emitted upon a successful block, through a block status setting operation.

event Blocked(uint256 indexed byProfileId, uint256 idOfProfileBlocked, address transactionExecutor, uint256 timestamp);

Unblocked

Emitted upon a successful unblock, through a block status setting operation.

event Unblocked(
    uint256 indexed byProfileId, uint256 idOfProfileUnblocked, address transactionExecutor, uint256 timestamp
);

CollectNFTTransferred

Emitted via callback when a collectNFT is transferred.

event CollectNFTTransferred(
    uint256 indexed profileId,
    uint256 indexed pubId,
    uint256 indexed collectNFTId,
    address from,
    address to,
    uint256 timestamp
);

TreasurySet

Emitted when the treasury address is set.

event TreasurySet(address indexed prevTreasury, address indexed newTreasury, uint256 timestamp);

TreasuryFeeSet

Emitted when the treasury fee is set.

event TreasuryFeeSet(uint16 indexed prevTreasuryFee, uint16 indexed newTreasuryFee, uint256 timestamp);

ProfileMetadataSet

Emitted when the metadata associated with a profile is set in the LensPeriphery.

event ProfileMetadataSet(uint256 indexed profileId, string metadata, address transactionExecutor, uint256 timestamp);

TokenGuardianStateChanged

Emitted when an address' Profile Guardian state change is triggered.

event TokenGuardianStateChanged(
    address indexed wallet, bool indexed enabled, uint256 tokenGuardianDisablingTimestamp, uint256 timestamp
);

NonceUpdated

Emitted when a signer's nonce is used and, as a consequence, the next available nonce is updated.

event NonceUpdated(address indexed signer, uint256 nonce, uint256 timestamp);

Typehash

Git Source

State Variables

ACT

bytes32 constant ACT = keccak256(
    "Act(uint256 publicationActedProfileId,uint256 publicationActedId,uint256 actorProfileId,uint256[] referrerProfileIds,uint256[] referrerPubIds,address actionModuleAddress,bytes actionModuleData,uint256 nonce,uint256 deadline)"
);

CHANGE_DELEGATED_EXECUTORS_CONFIG

bytes32 constant CHANGE_DELEGATED_EXECUTORS_CONFIG = keccak256(
    "ChangeDelegatedExecutorsConfig(uint256 delegatorProfileId,address[] delegatedExecutors,bool[] approvals,uint64 configNumber,bool switchToGivenConfig,uint256 nonce,uint256 deadline)"
);

COLLECT_LEGACY

bytes32 constant COLLECT_LEGACY = keccak256(
    "CollectLegacy(uint256 publicationCollectedProfileId,uint256 publicationCollectedId,uint256 collectorProfileId,uint256 referrerProfileId,uint256 referrerPubId,bytes collectModuleData,uint256 nonce,uint256 deadline)"
);

COMMENT

bytes32 constant COMMENT = keccak256(
    "Comment(uint256 profileId,string contentURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,address[] actionModules,bytes[] actionModulesInitDatas,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)"
);

EIP712_DOMAIN

bytes32 constant EIP712_DOMAIN =
    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

FOLLOW

bytes32 constant FOLLOW = keccak256(
    "Follow(uint256 followerProfileId,uint256[] idsOfProfilesToFollow,uint256[] followTokenIds,bytes[] datas,uint256 nonce,uint256 deadline)"
);

MIRROR

bytes32 constant MIRROR = keccak256(
    "Mirror(uint256 profileId,string metadataURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,uint256 nonce,uint256 deadline)"
);

POST

bytes32 constant POST = keccak256(
    "Post(uint256 profileId,string contentURI,address[] actionModules,bytes[] actionModulesInitDatas,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)"
);

QUOTE

bytes32 constant QUOTE = keccak256(
    "Quote(uint256 profileId,string contentURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,address[] actionModules,bytes[] actionModulesInitDatas,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)"
);

SET_BLOCK_STATUS

bytes32 constant SET_BLOCK_STATUS = keccak256(
    "SetBlockStatus(uint256 byProfileId,uint256[] idsOfProfilesToSetBlockStatus,bool[] blockStatus,uint256 nonce,uint256 deadline)"
);

SET_FOLLOW_MODULE

bytes32 constant SET_FOLLOW_MODULE = keccak256(
    "SetFollowModule(uint256 profileId,address followModule,bytes followModuleInitData,uint256 nonce,uint256 deadline)"
);

SET_PROFILE_METADATA_URI

bytes32 constant SET_PROFILE_METADATA_URI =
    keccak256("SetProfileMetadataURI(uint256 profileId,string metadataURI,uint256 nonce,uint256 deadline)");

UNFOLLOW

bytes32 constant UNFOLLOW =
    keccak256("Unfollow(uint256 unfollowerProfileId,uint256[] idsOfProfilesToUnfollow,uint256 nonce,uint256 deadline)");

Types

Git Source

Author: Lens Protocol

A standard library of data types used throughout the Lens Protocol.

Structs

TokenData

ERC721Timestamped storage. Contains the owner address and the mint timestamp for every NFT. Note: Instead of the owner address in the _tokenOwners private mapping, we now store it in the _tokenData mapping, alongside the mint timestamp.

struct TokenData {
    address owner;
    uint96 mintTimestamp;
}

FollowData

A struct containing token follow-related data.

struct FollowData {
    uint160 followerProfileId;
    uint48 originalFollowTimestamp;
    uint48 followTimestamp;
    uint256 profileIdAllowedToRecover;
}

EIP712Signature

A struct containing the necessary information to reconstruct an EIP-712 typed data signature.

struct EIP712Signature {
    address signer;
    uint8 v;
    bytes32 r;
    bytes32 s;
    uint256 deadline;
}

Profile

A struct containing profile data.

struct Profile {
    uint256 pubCount;
    address followModule;
    address followNFT;
    string __DEPRECATED__handle;
    string __DEPRECATED__imageURI;
    string __DEPRECATED__followNFTURI;
    string metadataURI;
}

Publication

A struct containing publication data.

struct Publication {
    uint256 pointedProfileId;
    uint256 pointedPubId;
    string contentURI;
    address referenceModule;
    address __DEPRECATED__collectModule;
    address __DEPRECATED__collectNFT;
    PublicationType pubType;
    uint256 rootProfileId;
    uint256 rootPubId;
    mapping(address => bool) actionModuleEnabled;
}

PublicationMemory

struct PublicationMemory {
    uint256 pointedProfileId;
    uint256 pointedPubId;
    string contentURI;
    address referenceModule;
    address __DEPRECATED__collectModule;
    address __DEPRECATED__collectNFT;
    PublicationType pubType;
    uint256 rootProfileId;
    uint256 rootPubId;
}

CreateProfileParams

A struct containing the parameters required for the createProfile() function.

struct CreateProfileParams {
    address to;
    address followModule;
    bytes followModuleInitData;
}

PostParams

A struct containing the parameters required for the post() function.

struct PostParams {
    uint256 profileId;
    string contentURI;
    address[] actionModules;
    bytes[] actionModulesInitDatas;
    address referenceModule;
    bytes referenceModuleInitData;
}

CommentParams

A struct containing the parameters required for the comment() function.

struct CommentParams {
    uint256 profileId;
    string contentURI;
    uint256 pointedProfileId;
    uint256 pointedPubId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    bytes referenceModuleData;
    address[] actionModules;
    bytes[] actionModulesInitDatas;
    address referenceModule;
    bytes referenceModuleInitData;
}

QuoteParams

A struct containing the parameters required for the quote() function.

struct QuoteParams {
    uint256 profileId;
    string contentURI;
    uint256 pointedProfileId;
    uint256 pointedPubId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    bytes referenceModuleData;
    address[] actionModules;
    bytes[] actionModulesInitDatas;
    address referenceModule;
    bytes referenceModuleInitData;
}

ReferencePubParams

A struct containing the parameters required for the comment() or quote() internal functions.

struct ReferencePubParams {
    uint256 profileId;
    string contentURI;
    uint256 pointedProfileId;
    uint256 pointedPubId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    bytes referenceModuleData;
    address[] actionModules;
    bytes[] actionModulesInitDatas;
    address referenceModule;
    bytes referenceModuleInitData;
}

MirrorParams

A struct containing the parameters required for the mirror() function.

struct MirrorParams {
    uint256 profileId;
    string metadataURI;
    uint256 pointedProfileId;
    uint256 pointedPubId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    bytes referenceModuleData;
}

LegacyCollectParams

Deprecated in V2: Will be removed after some time after upgrading to V2.

A struct containing the parameters required for the legacy collect() function.

The referrer can only be a mirror of the publication being collected.

struct LegacyCollectParams {
    uint256 publicationCollectedProfileId;
    uint256 publicationCollectedId;
    uint256 collectorProfileId;
    uint256 referrerProfileId;
    uint256 referrerPubId;
    bytes collectModuleData;
}

PublicationActionParams

A struct containing the parameters required for the action() function.

struct PublicationActionParams {
    uint256 publicationActedProfileId;
    uint256 publicationActedId;
    uint256 actorProfileId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    address actionModuleAddress;
    bytes actionModuleData;
}

ProcessActionParams

struct ProcessActionParams {
    uint256 publicationActedProfileId;
    uint256 publicationActedId;
    uint256 actorProfileId;
    address actorProfileOwner;
    address transactionExecutor;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    Types.PublicationType[] referrerPubTypes;
    bytes actionModuleData;
}

ProcessCollectParams

struct ProcessCollectParams {
    uint256 publicationCollectedProfileId;
    uint256 publicationCollectedId;
    uint256 collectorProfileId;
    address collectorProfileOwner;
    address transactionExecutor;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    Types.PublicationType[] referrerPubTypes;
    bytes data;
}

ProcessCommentParams

struct ProcessCommentParams {
    uint256 profileId;
    address transactionExecutor;
    uint256 pointedProfileId;
    uint256 pointedPubId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    Types.PublicationType[] referrerPubTypes;
    bytes data;
}

ProcessQuoteParams

struct ProcessQuoteParams {
    uint256 profileId;
    address transactionExecutor;
    uint256 pointedProfileId;
    uint256 pointedPubId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    Types.PublicationType[] referrerPubTypes;
    bytes data;
}

ProcessMirrorParams

struct ProcessMirrorParams {
    uint256 profileId;
    address transactionExecutor;
    uint256 pointedProfileId;
    uint256 pointedPubId;
    uint256[] referrerProfileIds;
    uint256[] referrerPubIds;
    Types.PublicationType[] referrerPubTypes;
    bytes data;
}

DelegatedExecutorsConfig

A struct containing a profile's delegated executors configuration.

struct DelegatedExecutorsConfig {
    mapping(uint256 => mapping(address => bool)) isApproved;
    uint64 configNumber;
    uint64 prevConfigNumber;
    uint64 maxConfigNumberSet;
}

TreasuryData

struct TreasuryData {
    address treasury;
    uint16 treasuryFeeBPS;
}

MigrationParams

struct MigrationParams {
    address lensHandlesAddress;
    address tokenHandleRegistryAddress;
    address legacyFeeFollowModule;
    address legacyProfileFollowModule;
    address newFeeFollowModule;
    address migrationAdmin;
}

Enums

ProtocolState

An enum containing the different states the protocol can be in, limiting certain actions.

enum ProtocolState {
    Unpaused,
    PublishingPaused,
    Paused
}

PublicationType

An enum specifically used in a helper function to easily retrieve the publication type for integrations.

enum PublicationType {
    Nonexistent,
    Post,
    Comment,
    Mirror,
    Quote
}

Contents

FollowTokenURILib

Git Source

Functions

getTokenURI

function getTokenURI(uint256 followTokenId, uint256 followedProfileId, uint256 originalFollowTimestamp)
    external
    pure
    returns (string memory);

_getSVGImageBase64Encoded

function _getSVGImageBase64Encoded(string memory followTokenIdAsString, string memory followedProfileIdAsString)
    private
    pure
    returns (string memory);

HandleTokenURILib

Git Source

Functions

getTokenURI

function getTokenURI(uint256 tokenId, string memory localName) external pure returns (string memory);

_getSVGImageBase64Encoded

function _getSVGImageBase64Encoded(string memory localName) private pure returns (string memory);

_localNameLengthToFontSize

Maps the local name length to a font size.

Gives the font size as a function of the local name length. This dynamic font size mapping ensures all handle token URIs will look nice when rendered as image.

function _localNameLengthToFontSize(uint256 localNameLength) internal pure returns (uint256);

Parameters

NameTypeDescription
localNameLengthuint256The handle's local name length.

Returns

NameTypeDescription
<none>uint256uint256 The font size.

ProfileTokenURILib

Git Source

Functions

getTokenURI

function getTokenURI(uint256 profileId) external view returns (string memory);

_getSVGImageBase64Encoded

function _getSVGImageBase64Encoded(string memory profileIdAsString) private pure returns (string memory);

TokenURIMainFontLib

Git Source

Functions

getFontName

function getFontName() internal pure returns (string memory);

getFontBase64Encoded

function getFontBase64Encoded() external pure returns (string memory);

TokenURISecondaryFontLib

Git Source

Functions

getFontName

function getFontName() internal pure returns (string memory);

getFontBase64Encoded

function getFontBase64Encoded() external pure returns (string memory);

ActionLib

Git Source

Functions

act

function act(
    Types.PublicationActionParams calldata publicationActionParams,
    address transactionExecutor,
    address actorProfileOwner
) external returns (bytes memory);

_isActionEnabled

function _isActionEnabled(Types.Publication storage _publication, address actionModuleAddress)
    private
    view
    returns (bool);

FollowLib

Git Source

Functions

follow

function follow(
    uint256 followerProfileId,
    address transactionExecutor,
    uint256[] calldata idsOfProfilesToFollow,
    uint256[] calldata followTokenIds,
    bytes[] calldata followModuleDatas
) external returns (uint256[] memory);

unfollow

function unfollow(uint256 unfollowerProfileId, address transactionExecutor, uint256[] calldata idsOfProfilesToUnfollow)
    external;

_deployFollowNFT

Deploys the given profile's Follow NFT contract.

function _deployFollowNFT(uint256 profileId) private returns (address);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile which Follow NFT should be deployed.

Returns

NameTypeDescription
<none>addressaddress The address of the deployed Follow NFT contract.

_follow

function _follow(
    uint256 followerProfileId,
    address transactionExecutor,
    uint256 idOfProfileToFollow,
    uint256 followTokenId,
    bytes calldata followModuleData
) private returns (uint256);

_processFollow

function _processFollow(ProcessFollowParams memory processFollowParams) private returns (uint256);

Structs

ProcessFollowParams

struct ProcessFollowParams {
    address followNFT;
    uint256 followerProfileId;
    address transactionExecutor;
    uint256 idOfProfileToFollow;
    uint256 followTokenId;
    address followModule;
    bytes followModuleData;
}

GovernanceLib

Git Source

State Variables

BPS_MAX

uint16 internal constant BPS_MAX = 10000;

Functions

setGovernance

Sets the governance address.

function setGovernance(address newGovernance) external;

Parameters

NameTypeDescription
newGovernanceaddressThe new governance address to set.

setEmergencyAdmin

Sets the emergency admin address.

function setEmergencyAdmin(address newEmergencyAdmin) external;

Parameters

NameTypeDescription
newEmergencyAdminaddressThe new governance address to set.

initState

Sets the protocol state, only meant to be called at initialization since this does not validate the caller.

function initState(Types.ProtocolState newState) external;

Parameters

NameTypeDescription
newStateTypes.ProtocolStateThe new protocol state to set.

setState

Sets the protocol state and validates the caller. The emergency admin can only pause further (Unpaused => PublishingPaused => Paused). Whereas governance can set any state.

function setState(Types.ProtocolState newState) external;

Parameters

NameTypeDescription
newStateTypes.ProtocolStateThe new protocol state to set.

_setState

function _setState(Types.ProtocolState newState) private returns (Types.ProtocolState);

whitelistProfileCreator

function whitelistProfileCreator(address profileCreator, bool whitelist) external;

setTreasury

function setTreasury(address newTreasury) internal;

setTreasuryFee

function setTreasuryFee(uint16 newTreasuryFee) internal;

LegacyCollectLib

Git Source

Author: Lens Protocol

Library containing the logic for legacy collect operation.

Functions

collect

function collect(
    Types.LegacyCollectParams calldata collectParams,
    address transactionExecutor,
    address collectorProfileOwner,
    address collectNFTImpl
) external returns (uint256);

_getOrDeployCollectNFT

function _getOrDeployCollectNFT(
    Types.Publication storage _collectedPublication,
    uint256 publicationCollectedProfileId,
    uint256 publicationCollectedId,
    address collectNFTImpl
) private returns (address);

_deployCollectNFT

Deploys the given profile's Collect NFT contract.

function _deployCollectNFT(uint256 profileId, uint256 pubId, address collectNFTImpl) private returns (address);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile which Collect NFT should be deployed.
pubIduint256The publication ID of the publication being collected, which Collect NFT should be deployed.
collectNFTImpladdressThe address of the Collect NFT implementation that should be used for the deployment.

Returns

NameTypeDescription
<none>addressaddress The address of the deployed Collect NFT contract.

Events

CollectedLegacy

Emitted upon a successful legacy collect action.

event CollectedLegacy(
    uint256 indexed publicationCollectedProfileId,
    uint256 indexed publicationCollectedId,
    address transactionExecutor,
    uint256 referrerProfileId,
    uint256 referrerPubId,
    bytes collectModuleData,
    uint256 timestamp
);

MetaTxLib

Git Source

Author: Lens Protocol NOTE: the functions in this contract operate under the assumption that the passed signer is already validated to either be the originator or one of their delegated executors.

User nonces are incremented from this library as well.

State Variables

EIP712_DOMAIN_VERSION

string constant EIP712_DOMAIN_VERSION = "2";

EIP712_DOMAIN_VERSION_HASH

bytes32 constant EIP712_DOMAIN_VERSION_HASH = keccak256(bytes(EIP712_DOMAIN_VERSION));

EIP1271_MAGIC_VALUE

bytes4 constant EIP1271_MAGIC_VALUE = 0x1626ba7e;

LENS_HUB_CACHED_POLYGON_DOMAIN_SEPARATOR

We store the domain separator and LensHub Proxy address as constants to save gas. keccak256( abi.encode( keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), keccak256('Lens Protocol Profiles'), // Contract Name keccak256('2'), // Version Hash 137, // Polygon Chain ID address(0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d) // Verifying Contract Address - LensHub Address ) );

bytes32 constant LENS_HUB_CACHED_POLYGON_DOMAIN_SEPARATOR =
    0xbf9544cf7d7a0338fc4f071be35409a61e51e9caef559305410ad74e16a05f2d;

LENS_HUB_ADDRESS

address constant LENS_HUB_ADDRESS = 0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d;

POLYGON_CHAIN_ID

uint256 constant POLYGON_CHAIN_ID = 137;

Functions

validateSetProfileMetadataURISignature

function validateSetProfileMetadataURISignature(
    Types.EIP712Signature calldata signature,
    uint256 profileId,
    string calldata metadataURI
) external;

validateSetFollowModuleSignature

function validateSetFollowModuleSignature(
    Types.EIP712Signature calldata signature,
    uint256 profileId,
    address followModule,
    bytes calldata followModuleInitData
) external;

validateChangeDelegatedExecutorsConfigSignature

function validateChangeDelegatedExecutorsConfigSignature(
    Types.EIP712Signature calldata signature,
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals,
    uint64 configNumber,
    bool switchToGivenConfig
) external;

validatePostSignature

function validatePostSignature(Types.EIP712Signature calldata signature, Types.PostParams calldata postParams)
    external;

validateCommentSignature

function validateCommentSignature(Types.EIP712Signature calldata signature, Types.CommentParams calldata commentParams)
    external;

validateQuoteSignature

function validateQuoteSignature(Types.EIP712Signature calldata signature, Types.QuoteParams calldata quoteParams)
    external;

validateMirrorSignature

function validateMirrorSignature(Types.EIP712Signature calldata signature, Types.MirrorParams calldata mirrorParams)
    external;

validateFollowSignature

function validateFollowSignature(
    Types.EIP712Signature calldata signature,
    uint256 followerProfileId,
    uint256[] calldata idsOfProfilesToFollow,
    uint256[] calldata followTokenIds,
    bytes[] calldata datas
) external;

validateUnfollowSignature

function validateUnfollowSignature(
    Types.EIP712Signature calldata signature,
    uint256 unfollowerProfileId,
    uint256[] calldata idsOfProfilesToUnfollow
) external;

validateSetBlockStatusSignature

function validateSetBlockStatusSignature(
    Types.EIP712Signature calldata signature,
    uint256 byProfileId,
    uint256[] calldata idsOfProfilesToSetBlockStatus,
    bool[] calldata blockStatus
) external;

validateLegacyCollectSignature

function validateLegacyCollectSignature(
    Types.EIP712Signature calldata signature,
    Types.LegacyCollectParams calldata collectParams
) external;

validateActSignature

function validateActSignature(
    Types.EIP712Signature calldata signature,
    Types.PublicationActionParams calldata publicationActionParams
) external;

calculateDomainSeparator

function calculateDomainSeparator() internal view returns (bytes32);

_validateRecoveredAddress

Wrapper for ecrecover to reduce code size, used in meta-tx specific functions.

function _validateRecoveredAddress(bytes32 digest, Types.EIP712Signature calldata signature) private view;

_calculateDigest

Calculates EIP712 digest based on the current DOMAIN_SEPARATOR.

function _calculateDigest(bytes32 hashedMessage) private view returns (bytes32);

Parameters

NameTypeDescription
hashedMessagebytes32The message hash from which the digest should be calculated.

Returns

NameTypeDescription
<none>bytes32bytes32 A 32-byte output representing the EIP712 digest.

_getNonceIncrementAndEmitEvent

This fetches a signer's current nonce and increments it so it's ready for the next meta-tx. Also emits the NonceUpdated event.

function _getNonceIncrementAndEmitEvent(address signer) private returns (uint256);

Parameters

NameTypeDescription
signeraddressThe address to get and increment the nonce for.

Returns

NameTypeDescription
<none>uint256uint256 The current nonce for the given signer prior to being incremented.

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bytes[] memory bytesArray) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bool[] memory boolArray) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(address[] memory addressArray) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(uint256[] memory uint256Array) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bytes32[] memory bytes32Array) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(string memory stringValue) private pure returns (bytes32);

_encodeUsingEip712Rules

function _encodeUsingEip712Rules(bytes memory bytesValue) private pure returns (bytes32);

ILegacyFeeFollowModule

Git Source

Functions

getProfileData

function getProfileData(uint256 profileId) external view returns (ProfileData memory);

Structs

ProfileData

struct ProfileData {
    address currency;
    uint256 amount;
    address recipient;
}

MigrationLib

Git Source

State Variables

LENS_PROTOCOL_PROFILE_ID

uint256 internal constant LENS_PROTOCOL_PROFILE_ID = 1;

DOT_LENS_SUFFIX_LENGTH

uint256 internal constant DOT_LENS_SUFFIX_LENGTH = 5;

Functions

batchMigrateProfiles

Migrates an array of profiles from V1 to V2. This function can be callable by anyone. We would still perform the migration in batches by ourselves, but good to allow users to migrate on their own if they want to.

function batchMigrateProfiles(
    uint256[] calldata profileIds,
    LensHandles lensHandles,
    TokenHandleRegistry tokenHandleRegistry
) external;

Parameters

NameTypeDescription
profileIdsuint256[]The array of profile IDs to migrate.
lensHandlesLensHandles
tokenHandleRegistryTokenHandleRegistry

_migrateProfile

Migrates a profile from V1 to V2.

We do not revert in any case, as we want to allow the migration to continue even if one profile fails (and it usually fails if already migrated or profileNFT moved).

Estimated gas cost of one profile migration is around 178k gas.

function _migrateProfile(uint256 profileId, LensHandles lensHandles, TokenHandleRegistry tokenHandleRegistry) private;

Parameters

NameTypeDescription
profileIduint256The profile ID to migrate.
lensHandlesLensHandles
tokenHandleRegistryTokenHandleRegistry

batchMigrateFollows

function batchMigrateFollows(
    uint256 followerProfileIds,
    uint256[] calldata idsOfProfileFollowed,
    uint256[] calldata followTokenIds
) external;

batchMigrateFollowers

function batchMigrateFollowers(
    uint256[] calldata followerProfileIds,
    uint256 idOfProfileFollowed,
    uint256[] calldata followTokenIds
) external;

_migrateFollow

function _migrateFollow(
    address followNFT,
    uint256 followerProfileId,
    uint256 idOfProfileFollowed,
    uint256 followTokenId
) private;

batchMigrateFollowModules

function batchMigrateFollowModules(
    uint256[] calldata profileIds,
    address legacyFeeFollowModule,
    address legacyProfileFollowModule,
    address newFeeFollowModule
) external;

Events

ProfileMigrated

event ProfileMigrated(uint256 profileId, address profileDestination, string handle, uint256 handleId);

ProfileLib

Git Source

Functions

MODULE_REGISTRY

function MODULE_REGISTRY() internal view returns (IModuleRegistry);

ownerOf

function ownerOf(uint256 profileId) internal view returns (address);

exists

function exists(uint256 profileId) internal view returns (bool);

createProfile

Creates a profile with the given parameters to the given address. Minting happens in the hub.

function createProfile(Types.CreateProfileParams calldata createProfileParams, uint256 profileId) external;

Parameters

NameTypeDescription
createProfileParamsTypes.CreateProfileParamsThe CreateProfileParams struct containing the following parameters: to: The address receiving the profile. followModule: The follow module to use, can be the zero address. followModuleInitData: The follow module initialization data, if any
profileIduint256The profile ID to associate with this profile NFT (token ID).

setFollowModule

Sets the follow module for a given profile.

function setFollowModule(
    uint256 profileId,
    address followModule,
    bytes calldata followModuleInitData,
    address transactionExecutor
) external;

Parameters

NameTypeDescription
profileIduint256The profile ID to set the follow module for.
followModuleaddressThe follow module to set for the given profile, if any.
followModuleInitDatabytesThe data to pass to the follow module for profile initialization.
transactionExecutoraddress

setProfileMetadataURI

function setProfileMetadataURI(uint256 profileId, string calldata metadataURI, address transactionExecutor) external;

_initFollowModule

function _initFollowModule(
    uint256 profileId,
    address transactionExecutor,
    address followModule,
    bytes memory followModuleInitData
) private returns (bytes memory);

setBlockStatus

function setBlockStatus(
    uint256 byProfileId,
    uint256[] calldata idsOfProfilesToSetBlockStatus,
    bool[] calldata blockStatus,
    address transactionExecutor
) external;

switchToNewFreshDelegatedExecutorsConfig

function switchToNewFreshDelegatedExecutorsConfig(uint256 profileId) external;

changeDelegatedExecutorsConfig

function changeDelegatedExecutorsConfig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals
) external;

changeGivenDelegatedExecutorsConfig

function changeGivenDelegatedExecutorsConfig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals,
    uint64 configNumber,
    bool switchToGivenConfig
) external;

isExecutorApproved

function isExecutorApproved(uint256 delegatorProfileId, address delegatedExecutor) external view returns (bool);

_changeDelegatedExecutorsConfig

function _changeDelegatedExecutorsConfig(
    Types.DelegatedExecutorsConfig storage _delegatedExecutorsConfig,
    uint256 delegatorProfileId,
    address[] memory delegatedExecutors,
    bool[] memory approvals,
    uint64 configNumber,
    bool switchToGivenConfig
) private;

_prepareStorageToApplyChangesUnderGivenConfig

function _prepareStorageToApplyChangesUnderGivenConfig(
    Types.DelegatedExecutorsConfig storage _delegatedExecutorsConfig,
    uint64 configNumber,
    bool switchToGivenConfig
) private returns (bool);

_setFollowModule

function _setFollowModule(
    uint256 profileId,
    address followModule,
    bytes calldata followModuleInitData,
    address transactionExecutor
) private;

PublicationLib

Git Source

Functions

MODULE_REGISTRY

function MODULE_REGISTRY() internal view returns (IModuleRegistry);

post

Publishes a post to a given profile.

function post(Types.PostParams calldata postParams, address transactionExecutor) external returns (uint256);

Parameters

NameTypeDescription
postParamsTypes.PostParamsThe PostParams struct.
transactionExecutoraddress

Returns

NameTypeDescription
<none>uint256uint256 The created publication's pubId.

comment

Publishes a comment to a given profile via signature.

function comment(Types.CommentParams calldata commentParams, address transactionExecutor) external returns (uint256);

Parameters

NameTypeDescription
commentParamsTypes.CommentParamsthe CommentParams struct.
transactionExecutoraddress

Returns

NameTypeDescription
<none>uint256uint256 The created publication's pubId.

mirror

Publishes a mirror to a given profile.

function mirror(Types.MirrorParams calldata mirrorParams, address transactionExecutor) external returns (uint256);

Parameters

NameTypeDescription
mirrorParamsTypes.MirrorParamsthe MirrorParams struct.
transactionExecutoraddress

Returns

NameTypeDescription
<none>uint256uint256 The created publication's pubId.

quote

Publishes a quote publication to a given profile via signature.

function quote(Types.QuoteParams calldata quoteParams, address transactionExecutor) external returns (uint256);

Parameters

NameTypeDescription
quoteParamsTypes.QuoteParamsthe QuoteParams struct.
transactionExecutoraddress

Returns

NameTypeDescription
<none>uint256uint256 The created publication's pubId.

getPublicationType

function getPublicationType(uint256 profileId, uint256 pubId) internal view returns (Types.PublicationType);

getContentURI

function getContentURI(uint256 profileId, uint256 pubId) external view returns (string memory);

_asReferencePubParams

function _asReferencePubParams(Types.QuoteParams calldata quoteParams)
    private
    pure
    returns (Types.ReferencePubParams calldata referencePubParams);

_asReferencePubParams

function _asReferencePubParams(Types.CommentParams calldata commentParams)
    private
    pure
    returns (Types.ReferencePubParams calldata referencePubParams);

_createReferencePublication

function _createReferencePublication(
    Types.ReferencePubParams calldata referencePubParams,
    address transactionExecutor,
    Types.PublicationType referencePubType
) private returns (uint256, bytes[] memory, bytes memory, Types.PublicationType[] memory);

_fillReferencePublicationStorage

function _fillReferencePublicationStorage(
    Types.ReferencePubParams calldata referencePubParams,
    Types.PublicationType referencePubType
) private returns (uint256, uint256);

_fillRootOfPublicationInStorage

function _fillRootOfPublicationInStorage(
    Types.Publication storage _publication,
    uint256 pointedProfileId,
    uint256 pointedPubId
) internal returns (uint256);

_processCommentIfNeeded

function _processCommentIfNeeded(
    Types.CommentParams calldata commentParams,
    address transactionExecutor,
    Types.PublicationType[] memory referrerPubTypes
) private returns (bytes memory);

_processQuoteIfNeeded

Equivalent to reverting with the returned error selector if the length is not zero.

function _processQuoteIfNeeded(
    Types.QuoteParams calldata quoteParams,
    address transactionExecutor,
    Types.PublicationType[] memory referrerPubTypes
) private returns (bytes memory);

_processMirrorIfNeeded

Equivalent to reverting with the returned error selector if the length is not zero.

function _processMirrorIfNeeded(
    Types.MirrorParams calldata mirrorParams,
    address transactionExecutor,
    Types.PublicationType[] memory referrerPubTypes
) private returns (bytes memory);

_initPubActionModules

function _initPubActionModules(InitActionModuleParams memory params) private returns (bytes[] memory);

_initPubReferenceModule

function _initPubReferenceModule(InitReferenceModuleParams memory params) private returns (bytes memory);

Structs

InitActionModuleParams

Equivalent to reverting with the returned error selector if the length is not zero.

struct InitActionModuleParams {
    uint256 profileId;
    address transactionExecutor;
    uint256 pubId;
    address[] actionModules;
    bytes[] actionModulesInitDatas;
}

InitReferenceModuleParams

struct InitReferenceModuleParams {
    uint256 profileId;
    address transactionExecutor;
    uint256 pubId;
    address referenceModule;
    bytes referenceModuleInitData;
}

StorageLib

Git Source

State Variables

TOKEN_DATA_MAPPING_SLOT

uint256 constant TOKEN_DATA_MAPPING_SLOT = 2;

SIG_NONCES_MAPPING_SLOT

uint256 constant SIG_NONCES_MAPPING_SLOT = 10;

LAST_INITIALIZED_REVISION_SLOT

uint256 constant LAST_INITIALIZED_REVISION_SLOT = 11;

PROTOCOL_STATE_SLOT

uint256 constant PROTOCOL_STATE_SLOT = 12;

PROFILE_CREATOR_WHITELIST_MAPPING_SLOT

uint256 constant PROFILE_CREATOR_WHITELIST_MAPPING_SLOT = 13;

PROFILE_ID_BY_HANDLE_HASH_MAPPING_SLOT

uint256 constant PROFILE_ID_BY_HANDLE_HASH_MAPPING_SLOT = 18;

PROFILES_MAPPING_SLOT

uint256 constant PROFILES_MAPPING_SLOT = 19;

PUBLICATIONS_MAPPING_SLOT

uint256 constant PUBLICATIONS_MAPPING_SLOT = 20;

PROFILE_COUNTER_SLOT

uint256 constant PROFILE_COUNTER_SLOT = 22;

GOVERNANCE_SLOT

uint256 constant GOVERNANCE_SLOT = 23;

EMERGENCY_ADMIN_SLOT

uint256 constant EMERGENCY_ADMIN_SLOT = 24;

TOKEN_GUARDIAN_DISABLING_TIMESTAMP_MAPPING_SLOT

Introduced in Lens V1.3: ///

uint256 constant TOKEN_GUARDIAN_DISABLING_TIMESTAMP_MAPPING_SLOT = 25;

DELEGATED_EXECUTOR_CONFIG_MAPPING_SLOT

Introduced in Lens V2: ///

uint256 constant DELEGATED_EXECUTOR_CONFIG_MAPPING_SLOT = 26;

BLOCKED_STATUS_MAPPING_SLOT

uint256 constant BLOCKED_STATUS_MAPPING_SLOT = 27;

PROFILE_ROYALTIES_BPS_SLOT

uint256 constant PROFILE_ROYALTIES_BPS_SLOT = 28;

MIGRATION_ADMINS_WHITELISTED_MAPPING_SLOT

uint256 constant MIGRATION_ADMINS_WHITELISTED_MAPPING_SLOT = 29;

TREASURY_DATA_SLOT

uint256 constant TREASURY_DATA_SLOT = 30;

Functions

getPublication

function getPublication(uint256 profileId, uint256 pubId)
    internal
    pure
    returns (Types.Publication storage _publication);

getPublicationMemory

function getPublicationMemory(uint256 profileId, uint256 pubId)
    internal
    pure
    returns (Types.PublicationMemory memory);

getProfile

function getProfile(uint256 profileId) internal pure returns (Types.Profile storage _profiles);

getDelegatedExecutorsConfig

function getDelegatedExecutorsConfig(uint256 delegatorProfileId)
    internal
    pure
    returns (Types.DelegatedExecutorsConfig storage _delegatedExecutorsConfig);

tokenGuardianDisablingTimestamp

function tokenGuardianDisablingTimestamp()
    internal
    pure
    returns (mapping(address => uint256) storage _tokenGuardianDisablingTimestamp);

getTokenData

function getTokenData(uint256 tokenId) internal pure returns (Types.TokenData storage _tokenData);

blockedStatus

function blockedStatus(uint256 blockerProfileId)
    internal
    pure
    returns (mapping(uint256 => bool) storage _blockedStatus);

nonces

function nonces() internal pure returns (mapping(address => uint256) storage _nonces);

profileIdByHandleHash

function profileIdByHandleHash() internal pure returns (mapping(bytes32 => uint256) storage _profileIdByHandleHash);

profileCreatorWhitelisted

function profileCreatorWhitelisted()
    internal
    pure
    returns (mapping(address => bool) storage _profileCreatorWhitelisted);

migrationAdminWhitelisted

function migrationAdminWhitelisted()
    internal
    pure
    returns (mapping(address => bool) storage _migrationAdminWhitelisted);

getGovernance

function getGovernance() internal view returns (address _governance);

setGovernance

function setGovernance(address newGovernance) internal;

getEmergencyAdmin

function getEmergencyAdmin() internal view returns (address _emergencyAdmin);

setEmergencyAdmin

function setEmergencyAdmin(address newEmergencyAdmin) internal;

getState

function getState() internal view returns (Types.ProtocolState _state);

setState

function setState(Types.ProtocolState newState) internal;

getLastInitializedRevision

function getLastInitializedRevision() internal view returns (uint256 _lastInitializedRevision);

setLastInitializedRevision

function setLastInitializedRevision(uint256 newLastInitializedRevision) internal;

getTreasuryData

function getTreasuryData() internal pure returns (Types.TreasuryData storage _treasuryData);

ValidationLib

Git Source

Author: Lens Protocol

Functions

validatePointedPub

function validatePointedPub(uint256 profileId, uint256 pubId) internal view;

validateAddressIsProfileOwner

function validateAddressIsProfileOwner(address expectedProfileOwner, uint256 profileId) internal view;

validateAddressIsProfileOwnerOrDelegatedExecutor

function validateAddressIsProfileOwnerOrDelegatedExecutor(address expectedOwnerOrDelegatedExecutor, uint256 profileId)
    internal
    view;

validateAddressIsDelegatedExecutor

function validateAddressIsDelegatedExecutor(address expectedDelegatedExecutor, uint256 delegatorProfileId)
    internal
    view;

validateProfileCreatorWhitelisted

function validateProfileCreatorWhitelisted(address profileCreator) internal view;

validateNotBlocked

function validateNotBlocked(uint256 profile, uint256 byProfile) internal view;

validateNotBlocked

function validateNotBlocked(uint256 profile, uint256 byProfile, bool unidirectionalCheck) internal view;

validateProfileExists

function validateProfileExists(uint256 profileId) internal view;

validateCallerIsGovernance

function validateCallerIsGovernance() internal view;

validateReferrersAndGetReferrersPubTypes

function validateReferrersAndGetReferrersPubTypes(
    uint256[] memory referrerProfileIds,
    uint256[] memory referrerPubIds,
    uint256 targetedProfileId,
    uint256 targetedPubId
) internal view returns (Types.PublicationType[] memory);

validateLegacyCollectReferrer

function validateLegacyCollectReferrer(
    uint256 referrerProfileId,
    uint256 referrerPubId,
    uint256 publicationCollectedProfileId,
    uint256 publicationCollectedId
) external view;

_validateReferrerAndGetReferrerPubType

function _validateReferrerAndGetReferrerPubType(
    uint256 referrerProfileId,
    uint256 referrerPubId,
    uint256 targetedProfileId,
    uint256 targetedPubId
) private view returns (Types.PublicationType);

_validateReferrerAsPost

function _validateReferrerAsPost(
    uint256 referrerProfileId,
    uint256 referrerPubId,
    uint256 targetedProfileId,
    uint256 targetedPubId
) private view;

_validateReferrerAsMirrorOrCommentOrQuote

Validates that the referrer publication and the interacted publication are linked.

function _validateReferrerAsMirrorOrCommentOrQuote(
    uint256 referrerProfileId,
    uint256 referrerPubId,
    uint256 targetedProfileId,
    uint256 targetedPubId
) private view;

Parameters

NameTypeDescription
referrerProfileIduint256The profile id of the referrer.
referrerPubIduint256The publication id of the referrer.
targetedProfileIduint256The ID of the profile who authored the publication being acted or referenced.
targetedPubIduint256The pub ID being acted or referenced.

Contents

Contents

ControllableByContract

Git Source

Inherits: Ownable

State Variables

controllerContract

address public controllerContract;

Functions

onlyOwnerOrControllerContract

modifier onlyOwnerOrControllerContract();

constructor

constructor(address owner) Ownable;

clearControllerContract

function clearControllerContract() external onlyOwnerOrControllerContract;

setControllerContract

function setControllerContract(address newControllerContract) external onlyOwner;

Events

ControllerContractUpdated

event ControllerContractUpdated(address previousControllerContract, address newControllerContract);

Errors

Unauthorized

error Unauthorized();

Governance

Git Source

Inherits: ControllableByContract

State Variables

LENS_HUB

ILensHub public immutable LENS_HUB;

Functions

constructor

constructor(address lensHubAddress_, address governanceOwner_) ControllableByContract(governanceOwner_);

lensHub_setGovernance

ONLY GOVERNANCE OWNER ///

function lensHub_setGovernance(address newGovernance) external onlyOwner;

lensHub_setEmergencyAdmin

function lensHub_setEmergencyAdmin(address newEmergencyAdmin) external onlyOwner;

lensHub_whitelistProfileCreator

ONLY GOVERNANCE OWNER OR CONTROLLER CONTRACT ///

function lensHub_whitelistProfileCreator(address profileCreator, bool whitelist)
    external
    onlyOwnerOrControllerContract;

executeAsGovernance

function executeAsGovernance(address target, bytes calldata data)
    external
    payable
    onlyOwnerOrControllerContract
    returns (bytes memory);

LitAccessControl

Git Source

Author: Lens Protocol

This contract enables additional access control for encrypted publications on Lens by reporting whether an address owns or has control over a given profile.

State Variables

LENS_HUB

address internal immutable LENS_HUB;

COLLECT_PUB_ACTION

address internal immutable COLLECT_PUB_ACTION;

Functions

constructor

constructor(address lensHub, address collectPubAction);

hasAccess

Function used to check whether an address is the Owner or Delegated Executor of a profile.

function hasAccess(address requestorAddress, uint256 profileId, bytes memory) external view returns (bool);

Parameters

NameTypeDescription
requestorAddressaddressThe address to check ownership over a profile.
profileIduint256The ID of the profile being checked for ownership. param data Optional data parameter, which may be used in future upgrades.
<none>bytes

Returns

NameTypeDescription
<none>boolBoolean indicating whether address owns the profile or not.

isFollowing

Function used to check whether followerProfileId is following profileId and requestor is Owner/Delegated Executor of followerProfileId.

function isFollowing(address requestorAddress, uint256 profileId, uint256 followerProfileId, bytes memory)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
requestorAddressaddressThe address to check ownership over a profile.
profileIduint256The ID of the profile being followed.
followerProfileIduint256The ID of the following profile. param data Optional data parameter, which may be used in future upgrades.
<none>bytes

hasCollected

Function used to check whether an address owns or has collected the publication.

function hasCollected(
    address requestorAddress,
    uint256 publisherId,
    uint256 pubId,
    uint256 collectorProfileId,
    bytes memory
) external view returns (bool);

Parameters

NameTypeDescription
requestorAddressaddressThe address to check if it owns the collect NFT of the publication.
publisherIduint256ID of the profile who is the publisher of the publication.
pubIduint256ID of the publication.
collectorProfileIduint256ID of the collector profile (optional, will check if the profile owner owns the NFT) param data Optional data parameter, which may be used in future upgrades.
<none>bytes

Returns

NameTypeDescription
<none>boolBoolean indicating whether address owns the collect NFT of the publication or not.

_isOwnerOrDelegatedExecutor

Internal function used to check whether an address is the Owner or DelegatedExecutor of a profile.

function _isOwnerOrDelegatedExecutor(address requestorAddress, uint256 profileId) internal view returns (bool);

Parameters

NameTypeDescription
requestorAddressaddressThe address to check ownership over a profile.
profileIduint256The ID of the profile being checked for ownership.

Returns

NameTypeDescription
<none>boolBoolean indicating whether address owns the profile or is DelegatedExecutor of it.

ProxyAdmin

Git Source

Inherits: ControllableByContract

State Variables

LENS_HUB_PROXY

TransparentUpgradeableProxy public immutable LENS_HUB_PROXY;

previousImplementation

address public previousImplementation;

Functions

constructor

constructor(address lensHubAddress_, address previousImplementation_, address proxyAdminOwner_)
    ControllableByContract(proxyAdminOwner_);

currentImplementation

function currentImplementation() external returns (address);

rollbackLastUpgrade

ONLY PROXY ADMIN OWNER ///

function rollbackLastUpgrade() external onlyOwner;

proxy_changeAdmin

function proxy_changeAdmin(address newAdmin) external onlyOwner;

proxy_upgrade

ONLY PROXY ADMIN OWNER OR CONTROLLER CONTRACT ///

function proxy_upgrade(address newImplementation) external onlyOwnerOrControllerContract;

proxy_upgradeAndCall

function proxy_upgradeAndCall(address newImplementation, bytes calldata data) external onlyOwnerOrControllerContract;

ImmutableOwnable

Git Source

State Variables

OWNER

address public immutable OWNER;

LENS_HUB

address public immutable LENS_HUB;

Functions

onlyOwner

modifier onlyOwner();

onlyOwnerOrHub

modifier onlyOwnerOrHub();

constructor

constructor(address owner, address lensHub);

Errors

OnlyOwner

error OnlyOwner();

OnlyOwnerOrHub

error OnlyOwnerOrHub();

LegacyCollectNFT

Git Source

Inherits: LensBaseERC721, ERC2981CollectionRoyalties, ICollectNFT

Author: Lens Protocol

This is the NFT contract that is minted upon collecting a given publication. It is cloned upon the first collect for a given publication, and the token URI points to the original publication's contentURI.

This is the Legacy CollectNFT that is used for Legacy Lens V1 publications. The new CollectNFT was introduced in Lens V2 with the only difference that it is restricted by the Action Module instead of the LensHub.

State Variables

HUB

address public immutable HUB;

_profileId

uint256 internal _profileId;

_pubId

uint256 internal _pubId;

_tokenIdCounter

uint256 internal _tokenIdCounter;

_initialized

bool private _initialized;

_royaltiesInBasisPoints

uint256 internal _royaltiesInBasisPoints;

Functions

constructor

constructor(address hub);

initialize

Initializes the collect NFT, setting the feed as the privileged minter, storing the collected publication pointer and initializing the name and symbol in the LensNFTBase contract.

function initialize(uint256 profileId, uint256 pubId) external override;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile in the hub that this Collect NFT points to.
pubIduint256The profile publication ID in the hub that this Collect NFT points to.

mint

Mints a collect NFT to the specified address. This can only be called by the hub and is called upon collection.

function mint(address to) external override returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the NFT to.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the minted token ID.

getSourcePublicationPointer

Returns the source publication of this collect NFT.

function getSourcePublicationPointer() external view override returns (uint256, uint256);

Returns

NameTypeDescription
<none>uint256tuple First is the profile ID, and second is the publication ID.
<none>uint256

tokenURI

function tokenURI(uint256 tokenId) public view override returns (string memory);

name

See {IERC721Metadata-name}.

function name() public view override returns (string memory);

symbol

See {IERC721Metadata-symbol}.

function symbol() public pure override returns (string memory);

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC2981CollectionRoyalties, LensBaseERC721)
    returns (bool);

_getReceiver

function _getReceiver(uint256) internal view override returns (address);

_beforeRoyaltiesSet

function _beforeRoyaltiesSet(uint256) internal view override;

_getRoyaltiesInBasisPointsSlot

function _getRoyaltiesInBasisPointsSlot() internal pure override returns (uint256);

LensHubInitializable

Git Source

Inherits: LensHub, VersionedInitializable, ILensHubInitializable

Author: Lens Protocol

Extension of LensHub contract that includes initialization for fresh deployments.

State Variables

REVISION

uint256 internal constant REVISION = 1;

Functions

constructor

constructor(
    address followNFTImpl,
    address collectNFTImpl,
    address moduleRegistry,
    uint256 tokenGuardianCooldown,
    Types.MigrationParams memory migrationParams
) LensHub(followNFTImpl, collectNFTImpl, moduleRegistry, tokenGuardianCooldown, migrationParams);

initialize

Initializes the LensHub, setting the initial governance address, the name and symbol of the profiles in the LensNFTBase contract, and Protocol State (Paused).

This is assuming a proxy pattern is implemented.

function initialize(string calldata name, string calldata symbol, address newGovernance)
    external
    override
    initializer;

Parameters

NameTypeDescription
namestringThe name of the Profile NFT.
symbolstringThe symbol of the Profile NFT.
newGovernanceaddressThe governance address to set.

getRevision

function getRevision() internal pure virtual override returns (uint256);

LensV2Migration

Git Source

State Variables

FEE_FOLLOW_MODULE

address internal immutable FEE_FOLLOW_MODULE;

PROFILE_FOLLOW_MODULE

address internal immutable PROFILE_FOLLOW_MODULE;

NEW_FEE_FOLLOW_MODULE

address internal immutable NEW_FEE_FOLLOW_MODULE;

lensHandles

LensHandles internal immutable lensHandles;

tokenHandleRegistry

TokenHandleRegistry internal immutable tokenHandleRegistry;

Functions

constructor

constructor(Types.MigrationParams memory migrationParams);

batchMigrateProfiles

function batchMigrateProfiles(uint256[] calldata profileIds) external;

batchMigrateFollows

function batchMigrateFollows(
    uint256 followerProfileId,
    uint256[] calldata idsOfProfileFollowed,
    uint256[] calldata followTokenIds
) external;

batchMigrateFollowers

function batchMigrateFollowers(
    uint256[] calldata followerProfileIds,
    uint256 idOfProfileFollowed,
    uint256[] calldata followTokenIds
) external;

batchMigrateFollowModules

function batchMigrateFollowModules(uint256[] calldata profileIds) external;

getProfileIdByHandleHash

function getProfileIdByHandleHash(bytes32 handleHash) external view returns (uint256);

setMigrationAdmins

function setMigrationAdmins(address[] memory migrationAdmins, bool whitelisted) external;

LensV2UpgradeContract

Git Source

Inherits: ImmutableOwnable

State Variables

PROXY_ADMIN

ProxyAdmin public immutable PROXY_ADMIN;

GOVERNANCE

Governance public immutable GOVERNANCE;

newImplementation

address public immutable newImplementation;

Functions

constructor

constructor(
    address proxyAdminAddress,
    address governanceAddress,
    address owner,
    address lensHub,
    address newImplementationAddress
) ImmutableOwnable(owner, lensHub);

executeLensV2Upgrade

function executeLensV2Upgrade() external onlyOwner;

_upgrade

function _upgrade() internal;

ModuleRegistry

Git Source

Inherits: IModuleRegistry

State Variables

registeredModules

mapping(address moduleAddress => uint256 moduleTypesBitmap) internal registeredModules;

registeredErc20Currencies

mapping(address erc20CurrencyAddress => bool) internal registeredErc20Currencies;

Functions

registerModule

function registerModule(address moduleAddress, uint256 moduleType) public returns (bool registrationWasPerformed);

getModuleTypes

function getModuleTypes(address moduleAddress) public view returns (uint256);

isModuleRegistered

function isModuleRegistered(address moduleAddress) external view returns (bool);

isModuleRegisteredAs

function isModuleRegisteredAs(address moduleAddress, uint256 moduleType) public view returns (bool);

registerErc20Currency

function registerErc20Currency(address currencyAddress) public returns (bool registrationWasPerformed);

isErc20CurrencyRegistered

function isErc20CurrencyRegistered(address currencyAddress) external view returns (bool);

Events

ModuleRegistered

event ModuleRegistered(address indexed moduleAddress, uint256 indexed moduleType, uint256 timestamp);

erc20CurrencyRegistered

event erc20CurrencyRegistered(
    address indexed erc20CurrencyAddress, string name, string symbol, uint8 decimals, uint256 timestamp
);

ProfileCreationProxy

Git Source

Inherits: ImmutableOwnable

Author: Lens Protocol

This is an ownable proxy contract that enforces ".lens" handle suffixes at profile creation. Only the owner can create profiles.

State Variables

LENS_HANDLES

ILensHandles immutable LENS_HANDLES;

TOKEN_HANDLE_REGISTRY

ITokenHandleRegistry immutable TOKEN_HANDLE_REGISTRY;

Functions

constructor

constructor(address owner, address hub, address lensHandles, address tokenHandleRegistry)
    ImmutableOwnable(owner, hub);

proxyCreateProfile

function proxyCreateProfile(Types.CreateProfileParams calldata createProfileParams)
    external
    onlyOwner
    returns (uint256);

proxyCreateProfileWithHandle

function proxyCreateProfileWithHandle(Types.CreateProfileParams memory createProfileParams, string calldata handle)
    external
    onlyOwner
    returns (uint256, uint256);

proxyCreateHandle

function proxyCreateHandle(address to, string calldata handle) external onlyOwner returns (uint256);

Errors

ProfileAlreadyExists

error ProfileAlreadyExists();

Contents

Contents

Contents

Contents

BaseFeeCollectModule

Git Source

Inherits: FeeModuleBase, ActionRestricted, IBaseFeeCollectModule

Author: Lens Protocol

This is base Lens CollectModule implementation, allowing customization of time to collect, number of collects and Followers-only restriction. Charges a fee for collect and distributing it among Receiver/Referrals/Treasury.

Here we use "Base" terminology to anything that represents this base functionality (base structs, base functions, base storage). Other collect modules can be built on top of the "Base" by inheriting from this contract and overriding functions. This contract is marked "abstract" as it requires you to implement initializePublicationCollectModule and getPublicationData functions when you inherit from it. See SimpleFeeCollectModule as an example implementation.

State Variables

HUB

address immutable HUB;

_dataByPublicationByProfile

mapping(uint256 => mapping(uint256 => BaseProfilePublicationData)) internal _dataByPublicationByProfile;

Functions

constructor

constructor(address hub, address actionModule) ActionRestricted(actionModule) FeeModuleBase(hub);

processCollect

Processes a collect by:

  1. Validating that collect action meets all needed criteria
  2. Processing the collect action either with or without referral
function processCollect(Types.ProcessCollectParams calldata processCollectParams)
    external
    virtual
    onlyActionModule
    returns (bytes memory);

Parameters

NameTypeDescription
processCollectParamsTypes.ProcessCollectParamsCollect action parameters (see Types.ProcessCollectParams struct)

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

getBasePublicationData

Returns the Base publication data for a given publication, or an empty struct if that publication was not initialized with this module.

function getBasePublicationData(uint256 profileId, uint256 pubId)
    public
    view
    virtual
    returns (BaseProfilePublicationData memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile mapped to the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>BaseProfilePublicationDataThe BaseProfilePublicationData struct mapped to that publication.

calculateFee

Calculates and returns the collect fee of a publication.

Override this function to use a different formula for the fee.

function calculateFee(Types.ProcessCollectParams calldata processCollectParams) public view virtual returns (uint160);

Returns

NameTypeDescription
<none>uint160The collect fee of the specified publication.

_validateBaseInitData

*Validates the Base parameters like:

  1. Is the currency whitelisted
  2. Is the referralFee in valid range
  3. Is the end of collects timestamp in valid range This should be called during initializePublicationCollectModule()*
function _validateBaseInitData(BaseFeeCollectModuleInitData memory baseInitData) internal virtual;

Parameters

NameTypeDescription
baseInitDataBaseFeeCollectModuleInitDataModule initialization data (see BaseFeeCollectModuleInitData struct)

_storeBasePublicationCollectParameters

Stores the initial module parameters This should be called during initializePublicationCollectModule()

function _storeBasePublicationCollectParameters(
    uint256 profileId,
    uint256 pubId,
    BaseFeeCollectModuleInitData memory baseInitData
) internal virtual;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The publication ID.
baseInitDataBaseFeeCollectModuleInitDataModule initialization data (see BaseFeeCollectModuleInitData struct)

_validateAndStoreCollect

*Validates the collect action by checking that:

  1. the collector is a follower (if enabled)
  2. the number of collects after the action doesn't surpass the collect limit (if enabled)
  3. the current block timestamp doesn't surpass the end timestamp (if enabled) This should be called during processCollect()*
function _validateAndStoreCollect(Types.ProcessCollectParams calldata processCollectParams) internal virtual;

_processCollect

*Internal processing of a collect:

  1. Calculation of fees
  2. Validation that fees are what collector expected
  3. Transfer of fees to recipient(-s) and treasury*
function _processCollect(Types.ProcessCollectParams calldata processCollectParams) internal virtual;

Parameters

NameTypeDescription
processCollectParamsTypes.ProcessCollectParamsParameters of the collect

_processCollectWithReferral

*Internal processing of a collect with a referrals (if any). Same as _processCollect, but also includes transfer to referrals (if any):

  1. Calculation of fees
  2. Validation that fees are what collector expected
  3. Transfer of fees to treasury, referrals (if any) and recipients*
function _processCollectWithReferral(Types.ProcessCollectParams calldata processCollectParams) internal virtual;

Parameters

NameTypeDescription
processCollectParamsTypes.ProcessCollectParamsParameters of the collect

_transferToRecipients

Tranfers the fee to recipient(-s) Override this to add additional functionality (e.g. multiple recipients)

function _transferToRecipients(
    Types.ProcessCollectParams calldata processCollectParams,
    address currency,
    uint256 amount
) internal virtual;

Parameters

NameTypeDescription
processCollectParamsTypes.ProcessCollectParamsParameters of the collect
currencyaddressCurrency of the transaction
amountuint256Amount to transfer to recipient(-s)

_transferToReferrals

Tranfers the part of fee to referral(-s) Override this to add additional functionality (e.g. different amounts to different referrals, etc)

function _transferToReferrals(
    Types.ProcessCollectParams calldata processCollectParams,
    address currency,
    uint256 amount
) internal virtual returns (uint256);

Parameters

NameTypeDescription
processCollectParamsTypes.ProcessCollectParamsParameters of the collect
currencyaddressCurrency of the transaction
amountuint256Amount of the fee after subtracting the Treasury part.

CollectNFT

Git Source

Inherits: LensBaseERC721, ERC2981CollectionRoyalties, ActionRestricted, ICollectNFT

Author: Lens Protocol

This is the NFT contract that is minted upon collecting a given publication. It is cloned upon the first collect for a given publication, and the token URI points to the original publication's contentURI.

This is the CollectNFT for Lens V2, it differs from LegacyCollectNFT that it's restricted to be called by an action module instead of LensHub.

State Variables

HUB

address public immutable HUB;

_profileId

uint256 internal _profileId;

_pubId

uint256 internal _pubId;

_tokenIdCounter

uint256 internal _tokenIdCounter;

_initialized

bool private _initialized;

_royaltiesInBasisPoints

uint256 internal _royaltiesInBasisPoints;

Functions

constructor

constructor(address hub, address actionModule) ActionRestricted(actionModule);

initialize

Initializes the collect NFT, setting the feed as the privileged minter, storing the collected publication pointer and initializing the name and symbol in the LensNFTBase contract.

function initialize(uint256 profileId, uint256 pubId) external override;

Parameters

NameTypeDescription
profileIduint256The token ID of the profile in the hub that this Collect NFT points to.
pubIduint256The profile publication ID in the hub that this Collect NFT points to.

mint

Mints a collect NFT to the specified address. This can only be called by the hub and is called upon collection.

function mint(address to) external override onlyActionModule returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the NFT to.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the minted token ID.

getSourcePublicationPointer

Returns the source publication of this collect NFT.

function getSourcePublicationPointer() external view override returns (uint256, uint256);

Returns

NameTypeDescription
<none>uint256tuple First is the profile ID, and second is the publication ID.
<none>uint256

tokenURI

function tokenURI(uint256 tokenId) public view override returns (string memory);

name

See {IERC721Metadata-name}.

function name() public view override returns (string memory);

symbol

See {IERC721Metadata-symbol}.

function symbol() public pure override returns (string memory);

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC2981CollectionRoyalties, LensBaseERC721)
    returns (bool);

_getReceiver

function _getReceiver(uint256) internal view override returns (address);

_beforeRoyaltiesSet

function _beforeRoyaltiesSet(uint256) internal view override;

_getRoyaltiesInBasisPointsSlot

function _getRoyaltiesInBasisPointsSlot() internal pure override returns (uint256);

CollectPublicationAction

Git Source

Inherits: HubRestricted, IPublicationActionModule

State Variables

COLLECT_NFT_IMPL

address public immutable COLLECT_NFT_IMPL;

_collectModuleRegistered

mapping(address collectModule => bool isWhitelisted) internal _collectModuleRegistered;

_collectDataByPub

mapping(uint256 profileId => mapping(uint256 pubId => CollectData collectData)) internal _collectDataByPub;

Functions

constructor

constructor(address hub, address collectNFTImpl) HubRestricted(hub);

registerCollectModule

function registerCollectModule(address collectModule) public returns (bool);

initializePublicationAction

function initializePublicationAction(uint256 profileId, uint256 pubId, address transactionExecutor, bytes calldata data)
    external
    override
    onlyHub
    returns (bytes memory);

processPublicationAction

function processPublicationAction(Types.ProcessActionParams calldata processActionParams)
    external
    override
    onlyHub
    returns (bytes memory);

_emitCollectedEvent

function _emitCollectedEvent(
    Types.ProcessActionParams calldata processActionParams,
    address collectNftRecipient,
    bytes memory collectData,
    bytes memory collectActionResult,
    address collectNFT,
    uint256 tokenId
) private;

getCollectData

function getCollectData(uint256 profileId, uint256 pubId) external view returns (CollectData memory);

_getOrDeployCollectNFT

function _getOrDeployCollectNFT(
    uint256 publicationCollectedProfileId,
    uint256 publicationCollectedId,
    address collectNFTImpl
) private returns (address);

_processCollect

function _processCollect(
    address collectModule,
    bytes memory collectData,
    Types.ProcessActionParams calldata processActionParams
) private returns (bytes memory);

_deployCollectNFT

function _deployCollectNFT(uint256 profileId, uint256 pubId, address collectNFTImpl) private returns (address);

isCollectModuleRegistered

function isCollectModuleRegistered(address collectModule) external view returns (bool);

Events

CollectModuleRegistered

event CollectModuleRegistered(address collectModule, uint256 timestamp);

CollectNFTDeployed

Emitted when a collectNFT clone is deployed using a lazy deployment pattern.

event CollectNFTDeployed(
    uint256 indexed profileId, uint256 indexed pubId, address indexed collectNFT, uint256 timestamp
);

Collected

Emitted upon a successful collect action.

event Collected(
    uint256 indexed collectedProfileId,
    uint256 indexed collectedPubId,
    uint256 indexed collectorProfileId,
    address nftRecipient,
    bytes collectActionData,
    bytes collectActionResult,
    address collectNFT,
    uint256 tokenId,
    address transactionExecutor,
    uint256 timestamp
);

Structs

CollectData

struct CollectData {
    address collectModule;
    address collectNFT;
}

RecipientData

Git Source

struct RecipientData {
    address recipient;
    uint16 split;
}

MultirecipientFeeCollectModuleInitData

Git Source

A struct containing the necessary data to initialize MultirecipientFeeCollectModule.

struct MultirecipientFeeCollectModuleInitData {
    uint160 amount;
    uint96 collectLimit;
    address currency;
    uint16 referralFee;
    bool followerOnly;
    uint72 endTimestamp;
    RecipientData[] recipients;
}

MultirecipientFeeCollectProfilePublicationData

Git Source

A struct containing the necessary data to execute collect actions on a publication.

struct MultirecipientFeeCollectProfilePublicationData {
    uint160 amount;
    uint96 collectLimit;
    address currency;
    uint96 currentCollects;
    uint16 referralFee;
    bool followerOnly;
    uint72 endTimestamp;
    RecipientData[] recipients;
}

TooManyRecipients

Git Source

error TooManyRecipients();

InvalidRecipientSplits

Git Source

error InvalidRecipientSplits();

RecipientSplitCannotBeZero

Git Source

error RecipientSplitCannotBeZero();

MultirecipientFeeCollectModule

Git Source

Inherits: BaseFeeCollectModule

Author: Lens Protocol

This is a simple Lens CollectModule implementation, allowing customization of time to collect, number of collects, splitting collect fee across multiple recipients, and whether only followers can collect. It is charging a fee for collect and distributing it among (one or up to five) Receivers, Referral, Treasury.

State Variables

_recipientsByPublicationByProfile

mapping(uint256 => mapping(uint256 => RecipientData[])) internal _recipientsByPublicationByProfile;

Functions

constructor

constructor(address hub, address actionModule) BaseFeeCollectModule(hub, actionModule);

initializePublicationCollectModule

Initializes data for a given publication being published.

function initializePublicationCollectModule(uint256 profileId, uint256 pubId, address, bytes calldata data)
    external
    override
    onlyActionModule
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
<none>address
databytesArbitrary data passed from the user! to be decoded.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

_validateAndStoreRecipients

Validates the recipients array and stores them to (a separate from Base) storage.

function _validateAndStoreRecipients(RecipientData[] memory recipients, uint256 profileId, uint256 pubId) internal;

Parameters

NameTypeDescription
recipientsRecipientData[]An array of recipients
profileIduint256The profile ID who is publishing the publication.
pubIduint256The associated publication's LensHub publication ID.

_transferToRecipients

Transfers the fee to multiple recipients.

function _transferToRecipients(
    Types.ProcessCollectParams calldata processCollectParams,
    address currency,
    uint256 amount
) internal override;

Parameters

NameTypeDescription
processCollectParamsTypes.ProcessCollectParamsParameters of the collect
currencyaddressCurrency of the transaction
amountuint256Amount to transfer to recipient(-s)

getPublicationData

Returns the publication data for a given publication, or an empty struct if that publication was not initialized with this module.

function getPublicationData(uint256 profileId, uint256 pubId)
    external
    view
    returns (MultirecipientFeeCollectProfilePublicationData memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile mapped to the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>MultirecipientFeeCollectProfilePublicationDataThe BaseProfilePublicationData struct mapped to that publication.

SimpleFeeCollectModule

Git Source

Inherits: BaseFeeCollectModule

Author: Lens Protocol

This is a simple Lens CollectModule implementation, allowing customization of time to collect, number of collects and whether only followers can collect. You can build your own collect modules by inheriting from BaseFeeCollectModule and adding your functionality along with getPublicationData function.

Functions

constructor

constructor(address hub, address actionModule) BaseFeeCollectModule(hub, actionModule);

initializePublicationCollectModule

This collect module levies a fee on collects and supports referrals. Thus, we need to decode data.

function initializePublicationCollectModule(uint256 profileId, uint256 pubId, address, bytes calldata data)
    external
    override
    onlyActionModule
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
<none>address
databytesThe arbitrary data parameter, decoded into BaseFeeCollectModuleInitData struct: amount: The collecting cost associated with this publication. 0 for free collect. collectLimit: The maximum number of collects for this publication. 0 for no limit. currency: The currency associated with this publication. referralFee: The referral fee associated with this publication. followerOnly: True if only followers of publisher may collect the post. endTimestamp: The end timestamp after which collecting is impossible. 0 for no expiry. recipient: Recipient of collect fees.

Returns

NameTypeDescription
<none>bytesAn abi encoded bytes parameter, which is the same as the passed data parameter.

getPublicationData

Returns the publication data for a given publication, or an empty struct if that publication was not initialized with this module.

function getPublicationData(uint256 profileId, uint256 pubId)
    external
    view
    virtual
    returns (BaseProfilePublicationData memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile mapped to the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>BaseProfilePublicationDataThe BaseProfilePublicationData struct mapped to that publication.

Contents

LensSeaDropCollection

Git Source

Inherits: ERC721SeaDropCloneable

State Variables

ROYALTIES_BPS

uint16 private constant ROYALTIES_BPS = 1_000;

HUB

address immutable HUB;

SEADROP_ACTION_MODULE

address immutable SEADROP_ACTION_MODULE;

DEFAULT_SEADROP

address immutable DEFAULT_SEADROP;

Functions

onlySeaDropActionModule

modifier onlySeaDropActionModule();

constructor

constructor(address lensHub, address seaDropActionModule, address defaultSeaDrop);

initialize

function initialize(
    address owner,
    string calldata name,
    string calldata symbol,
    address[] calldata allowedSeaDrops,
    MultiConfigureStruct calldata config
) external onlySeaDropActionModule;

_validateInitializationData

function _validateInitializationData(address[] calldata allowedSeaDrops, MultiConfigureStruct calldata config)
    internal
    view;

updateAllowedSeaDrop

Update the allowed SeaDrop contracts. Only the owner or administrator can use this function.

function updateAllowedSeaDrop(address[] calldata allowedSeaDrop) external virtual override onlyOwner;

Parameters

NameTypeDescription
allowedSeaDropaddress[]The allowed SeaDrop addresses.

updatePublicDrop

Update the public drop data for this NFT contract on SeaDrop. Only the owner can use this function.

function updatePublicDrop(address seaDropImpl, PublicDrop calldata publicDrop) external virtual override;

Parameters

NameTypeDescription
seaDropImpladdressThe allowed SeaDrop contract.
publicDropPublicDropThe public drop data.

updateAllowedFeeRecipient

Update the allowed fee recipient for this NFT contract on SeaDrop. Only the owner can set the allowed fee recipient.

function updateAllowedFeeRecipient(address seaDropImpl, address feeRecipient, bool allowed) external virtual override;

Parameters

NameTypeDescription
seaDropImpladdressThe allowed SeaDrop contract.
feeRecipientaddressThe new fee recipient.
allowedboolIf the fee recipient is allowed.

updatePayer

Update the allowed payers for this NFT contract on SeaDrop. Only the owner can use this function.

function updatePayer(address seaDropImpl, address payer, bool allowed) external virtual override;

Parameters

NameTypeDescription
seaDropImpladdressThe allowed SeaDrop contract.
payeraddressThe payer to update.
allowedboolWhether the payer is allowed.

Errors

OnlySeaDropActionModule

error OnlySeaDropActionModule();

FeesDoNotCoverLensTreasury

error FeesDoNotCoverLensTreasury();

InvalidParams

error InvalidParams();

SeaDropMintPublicationAction

Git Source

Inherits: HubRestricted, IPublicationActionModule

State Variables

MAX_BPS

uint256 constant MAX_BPS = 10_000;

SEADROP

ISeaDrop public immutable SEADROP;

WMATIC

IWMATIC public immutable WMATIC;

MODULE_REGISTRY

IModuleRegistry public immutable MODULE_REGISTRY;

_collectionDataByPub

mapping(uint256 profileId => mapping(uint256 pubId => CollectionData collectionData)) internal _collectionDataByPub;

lensSeaDropCollectionImpl

address public lensSeaDropCollectionImpl;

Functions

constructor

constructor(address hub, address moduleRegistry, address seaDrop, address wmatic) HubRestricted(hub);

deploySeaDropCollection

function deploySeaDropCollection(
    address owner,
    string memory name,
    string memory symbol,
    ERC721SeaDropStructsErrorsAndEvents.MultiConfigureStruct calldata config
) external returns (address);

setLensSeaDropCollectionImpl

function setLensSeaDropCollectionImpl(address newLensSeaDropCollectionImpl) external;

initializePublicationAction

function initializePublicationAction(uint256 profileId, uint256 pubId, address, bytes calldata data)
    external
    override
    onlyHub
    returns (bytes memory);

receive

receive() external payable;

withdrawToTreasury

function withdrawToTreasury(address currency) external;

processPublicationAction

function processPublicationAction(Types.ProcessActionParams calldata processActionParams)
    external
    override
    onlyHub
    returns (bytes memory);

rescaleFees

function rescaleFees(uint256 profileId, uint256 pubId) public;

_rescaleFees

function _rescaleFees(uint256 profileId, uint256 pubId, uint16 lensTreasuryFeeBps, PublicDrop memory publicDrop)
    internal;

_distributeFees

function _distributeFees(
    uint256 feesToDistribute,
    uint256 mintPaymentAmount,
    address lensTreasuryAddress,
    CollectionData memory collectionData,
    Types.ProcessActionParams calldata processActionParams
) internal;

_validateFees

function _validateFees(PublicDrop memory publicDrop, uint16 lensTreasuryFeeBps, uint16 referrersFeeBps) internal pure;

_validateFeesAndRescaleThemIfNecessary

function _validateFeesAndRescaleThemIfNecessary(
    uint256 profileId,
    uint256 pubId,
    PublicDrop memory publicDrop,
    uint16 lensTreasuryFeeBps,
    uint16 referrersFeeBps
) internal;

Events

SeaDropPublicationFeesRescaled

event SeaDropPublicationFeesRescaled(uint256 profileId, uint256 pubId, uint16 referrersFeeBps);

LensSeaDropCollectionDeployed

event LensSeaDropCollectionDeployed(
    address collectionAddress,
    address owner,
    string name,
    string symbol,
    ERC721SeaDropStructsErrorsAndEvents.MultiConfigureStruct config
);

Errors

WrongMintPaymentAmount

error WrongMintPaymentAmount();

SeaDropFeesNotReceived

error SeaDropFeesNotReceived();

ActionModuleNotAllowedAsPayer

error ActionModuleNotAllowedAsPayer();

ActionModuleNotAllowedAsFeeRecipient

error ActionModuleNotAllowedAsFeeRecipient();

MintPriceExceedsExpectedOne

error MintPriceExceedsExpectedOne();

NotEnoughFeesSet

error NotEnoughFeesSet();

Unauthorized

error Unauthorized();

Structs

CollectionData

struct CollectionData {
    address nftCollectionAddress;
    uint16 referrersFeeBps;
}

Contents

Errors

Git Source

Errors

FollowInvalid

error FollowInvalid();

ModuleDataMismatch

error ModuleDataMismatch();

NotHub

error NotHub();

InitParamsInvalid

error InitParamsInvalid();

InvalidParams

error InvalidParams();

MintLimitExceeded

error MintLimitExceeded();

CollectExpired

error CollectExpired();

NotActionModule

error NotActionModule();

CollectNotAllowed

error CollectNotAllowed();

AlreadyInitialized

error AlreadyInitialized();

Contents

FeeConfig

Git Source

A struct containing the necessary data to execute follow actions on a given profile.

struct FeeConfig {
    address currency;
    uint256 amount;
    address recipient;
}

FeeFollowModule

Git Source

Inherits: FeeModuleBase, HubRestricted, IFollowModule

Author: Lens Protocol

This follow module charges a fee for every follow.

State Variables

_feeConfig

mapping(uint256 profileId => FeeConfig config) internal _feeConfig;

Functions

constructor

constructor(address hub) FeeModuleBase(hub) HubRestricted(hub);

initializeFollowModule

Initializes a follow module for a given Lens profile.

function initializeFollowModule(uint256 profileId, address, bytes calldata data)
    external
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The Profile ID to initialize this follow module for.
<none>address
databytesThe arbitrary data parameter, decoded into: - address currency: The currency address, must be internally whitelisted. - uint256 amount: The currency total amount to charge. - address recipient: The custom recipient address to direct earnings to.

Returns

NameTypeDescription
<none>bytesbytes The encoded data to be emitted from the hub.

processFollow

Processes a follow by charging a fee.

function processFollow(
    uint256,
    uint256 followTokenId,
    address transactionExecutor,
    uint256 targetProfileId,
    bytes calldata data
) external override onlyHub returns (bytes memory);

Parameters

NameTypeDescription
<none>uint256
followTokenIduint256The Follow Token ID that is being used to follow. Zero if we are processing a new fresh follow, in this case, the follow ID assigned can be queried from the Follow NFT collection if needed.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).
targetProfileIduint256The token ID of the profile being followed.
databytesArbitrary data passed by the follower.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

getFeeConfig

Returns fee configuration for a given profile.

function getFeeConfig(uint256 profileId) external view returns (FeeConfig memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to query.

Returns

NameTypeDescription
<none>FeeConfigFeeConfig The FeeConfig struct mapped to that profile.

RevertFollowModule

Git Source

Inherits: IFollowModule

Author: Lens Protocol

This follow module rejects all follow attempts.

Functions

initializeFollowModule

Initializes a follow module for a given Lens profile.

function initializeFollowModule(uint256, address, bytes calldata) external pure override returns (bytes memory);

Parameters

NameTypeDescription
<none>uint256
<none>address
<none>bytes

Returns

NameTypeDescription
<none>bytesbytes The encoded data to be emitted from the hub.

processFollow

Processes a follow by rejecting it, reverting the transaction. Parameters are ignored.

function processFollow(uint256, uint256, address, uint256, bytes calldata)
    external
    pure
    override
    returns (bytes memory);

Parameters

NameTypeDescription
<none>uint256
<none>uint256
<none>address
<none>uint256
<none>bytes

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

Contents

BaseProfilePublicationData

Git Source

A struct containing the necessary data to execute collect actions on a publication.

struct BaseProfilePublicationData {
    uint160 amount;
    uint96 collectLimit;
    address currency;
    uint96 currentCollects;
    address recipient;
    uint16 referralFee;
    bool followerOnly;
    uint72 endTimestamp;
}

BaseFeeCollectModuleInitData

Git Source

A struct containing the necessary data to initialize this Base Collect Module.

struct BaseFeeCollectModuleInitData {
    uint160 amount;
    uint96 collectLimit;
    address currency;
    uint16 referralFee;
    bool followerOnly;
    uint72 endTimestamp;
    address recipient;
}

IBaseFeeCollectModule

Git Source

Inherits: ICollectModule

Functions

getBasePublicationData

Returns the Base publication data for a given publication, or an empty struct if that publication was not initialized with this module.

function getBasePublicationData(uint256 profileId, uint256 pubId)
    external
    view
    returns (BaseProfilePublicationData memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile mapped to the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>BaseProfilePublicationDataThe BaseProfilePublicationData struct mapped to that publication.

calculateFee

Calculates and returns the collect fee of a publication.

Override this function to use a different formula for the fee.

function calculateFee(Types.ProcessCollectParams calldata processCollectParams) external view returns (uint160);

Returns

NameTypeDescription
<none>uint160The collect fee of the specified publication.

IWMATIC

Git Source

Inherits: IERC20

Functions

withdraw

function withdraw(uint256 amountToUnwrap) external;

deposit

function deposit() external payable;

Contents

FollowValidationLib

Git Source

Author: Lens Protocol

A library contract that verifies that a user is following another user and reverts if not.

Functions

validateIsFollowing

function validateIsFollowing(address hub, uint256 followerProfileId, uint256 followedProfileId) internal view;

Contents

ModuleConfig

Git Source

Struct representing the module configuration for certain publication.

struct ModuleConfig {
    bool setUp;
    bool commentsRestricted;
    bool quotesRestricted;
    bool mirrorsRestricted;
    uint8 degreesOfSeparation;
    uint128 sourceProfile;
}

DegreesOfSeparationReferenceModule

Git Source

Inherits: HubRestricted, IReferenceModule

Author: Lens Protocol

This reference module allows to set a degree of separation n, and then allows to quote/comment/mirror only to profiles that are at most at n degrees of separation from the source profile, which is expected to be set as the author of the root publication.

State Variables

MAX_DEGREES_OF_SEPARATION

Because of the "Six degrees of separation" theory, in the long term, setting up 5, 6 or more degrees of separation will be almost equivalent to turning off the restriction. If we also take into account the gas cost of performing the validations on-chain, and the cost of off-chain computation of the path, makes sense to only support up to 3 degrees of separation.

uint8 public constant MAX_DEGREES_OF_SEPARATION = 2;

_moduleConfig

mapping(uint256 profileId => mapping(uint256 pubId => ModuleConfig config)) internal _moduleConfig;

Functions

constructor

constructor(address hub) HubRestricted(hub);

initializeReferenceModule

Initializes data for the given publication being published with this Reference module.

*The data param should have ABI-encoded the following information:

  • bool commentsRestricted: Indicates if the comment operation is restricted or open to everyone.
  • bool quotesRestricted: Indicates if the quote operation is restricted or open to everyone.
  • bool mirrorsRestricted: Indicates if the mirror operation is restricted or open to everyone.
  • uint8 degreesOfSeparation: The max degrees of separation allowed for restricted operations.
  • uint128 sourceProfile The ID of the profile from where the follower path should be started. Expected to be set as the author of the root publication.*
function initializeReferenceModule(uint256 profileId, uint256 pubId, address, bytes calldata data)
    external
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
<none>address
databytesArbitrary data passed from the user to be decoded by the Reference Module during initialization.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processComment

Processes a comment being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

It will apply the degrees of separation restriction if the publication has commentsRestricted enabled. The param processCommentParams.data has ABI-encoded the array of profile IDs representing the follower path between the source profile and the profile authoring the comment. In addition, if comments were restricted, inheritance of commenting restrictions will be enforced.

function processComment(Types.ProcessCommentParams calldata processCommentParams)
    external
    view
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
processCommentParamsTypes.ProcessCommentParamsThe parameters for processing a comment.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processQuote

Processes a quote being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

It will apply the degrees of separation restriction if the publication has quotesRestricted enabled. The param processQuoteParams.data has ABI-encoded the array of profile IDs representing the follower path between the source profile and the profile authoring the quote.

function processQuote(Types.ProcessQuoteParams calldata processQuoteParams)
    external
    view
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
processQuoteParamsTypes.ProcessQuoteParamsThe parameters for processing a quote.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processMirror

Processes a mirror being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

It will apply the degrees of separation restriction if the publication has mirrorsRestricted enabled. The param processMirrorParams.data has ABI-encoded the array of profile IDs representing the follower path between the source profile and the profile authoring the mirror.

function processMirror(Types.ProcessMirrorParams calldata processMirrorParams)
    external
    view
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
processMirrorParamsTypes.ProcessMirrorParamsThe parameters for processing a mirror.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

getModuleConfig

Gets the module configuration for the given publication.

function getModuleConfig(uint256 profileId, uint256 pubId) external view returns (ModuleConfig memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.

Returns

NameTypeDescription
<none>ModuleConfigModuleConfig The module configuration set for the given publication.

_validateDegreesOfSeparationRestriction

The data has encoded an array of integers, each integer is a profile ID, the whole array represents a path of n profiles. Let's define X --> Y as The owner of X is following Y. Then, being path[i] the i-th profile in the path, the following condition must be met for a given path of n profiles: sourceProfile --> path[0] --> path[1] --> path[2] --> ... --> path[n-2] --> path[n-1] --> profileId

function _validateDegreesOfSeparationRestriction(
    uint256 sourceProfile,
    uint256 profileId,
    uint8 degreesOfSeparation,
    uint256[] memory profilePath
) internal view;

Parameters

NameTypeDescription
sourceProfileuint256The ID of the profile from where the follower path should be started. Most likely to be the root publication's author.
profileIduint256The ID of the publication being published's author.
degreesOfSeparationuint8The degrees of separations configured for the given publication.
profilePathuint256[]The array of profile IDs representing the follower path between the source profile and the profile authoring the new publication (it could be a comment, a quote or a mirror of the pointed one).

_validateCommentInheritedConfigFromPointedPub

Validates that the comment configuration is inherited from pointed publication.

function _validateCommentInheritedConfigFromPointedPub(ModuleConfig memory pointedPubConfig, uint256 profileId)
    internal
    view;

Parameters

NameTypeDescription
pointedPubConfigModuleConfigThe pointed publication's degrees of separation module configuration.
profileIduint256The ID of the profile authoring the publication being processed.

Errors

InvalidDegreesOfSeparation

error InvalidDegreesOfSeparation();

OperationDisabled

error OperationDisabled();

ProfilePathExceedsDegreesOfSeparation

error ProfilePathExceedsDegreesOfSeparation();

NotInheritingPointedPubConfig

error NotInheritingPointedPubConfig();

FollowerOnlyReferenceModule

Git Source

Inherits: HubRestricted, IReferenceModule

Author: Lens Protocol

A simple reference module that validates that comments, quotes or mirrors originate from a profile that follows the profile of the original publication.

Functions

constructor

constructor(address hub) HubRestricted(hub);

initializeReferenceModule

Initializes data for the given publication being published with this Reference module.

There is nothing needed at initialization.

function initializeReferenceModule(uint256, uint256, address, bytes calldata) external pure returns (bytes memory);

Parameters

NameTypeDescription
<none>uint256
<none>uint256
<none>address
<none>bytes

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processComment

Processes a comment being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

Validates that the commenting profile's owner is a follower.

function processComment(Types.ProcessCommentParams calldata processCommentParams)
    external
    view
    override
    returns (bytes memory);

Parameters

NameTypeDescription
processCommentParamsTypes.ProcessCommentParamsThe parameters for processing a comment.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processQuote

Processes a quote being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

Validates that the quoting profile's owner is a follower.

function processQuote(Types.ProcessQuoteParams calldata processQuoteParams)
    external
    view
    override
    returns (bytes memory);

Parameters

NameTypeDescription
processQuoteParamsTypes.ProcessQuoteParamsThe parameters for processing a quote.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processMirror

Processes a mirror being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

Validates that the mirroring profile's owner is a follower.

function processMirror(Types.ProcessMirrorParams calldata processMirrorParams)
    external
    view
    override
    returns (bytes memory);

Parameters

NameTypeDescription
processMirrorParamsTypes.ProcessMirrorParamsThe parameters for processing a mirror.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

IToken

Git Source

Functions

balanceOf

Returns the amount of ERC20/ERC721 tokens owned by account.

function balanceOf(address account) external view returns (uint256);

GateParams

Git Source

A struct containing the necessary data to execute TokenGated references.

struct GateParams {
    address tokenAddress;
    uint256 minThreshold;
}

TokenGatedReferenceModule

Git Source

Inherits: HubRestricted, IReferenceModule

Author: Lens Protocol

A reference module that validates that the user who tries to reference has a required minimum balance of ERC20/ERC721 token.

State Variables

UINT256_BYTES

uint256 internal constant UINT256_BYTES = 32;

_gateParams

mapping(uint256 pointedProfileId => mapping(uint256 pointedPubId => GateParams gateParams)) internal _gateParams;

Functions

constructor

constructor(address hub) HubRestricted(hub);

initializeReferenceModule

Initializes data for the given publication being published with this Reference module.

The gating token address and minimum balance threshold is passed during initialization in data field.

function initializeReferenceModule(uint256 profileId, uint256 pubId, address, bytes calldata data)
    external
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile publishing the publication.
pubIduint256The associated publication's LensHub publication ID.
<none>address
databytesArbitrary data passed from the user to be decoded by the Reference Module during initialization.

Returns

NameTypeDescription
<none>bytesbytes Any custom ABI-encoded data. This will be a LensHub event params that can be used by indexers or UIs.

processComment

Processes a comment being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

Validates that the commenting profile's owner has enough balance of the gating token.

function processComment(Types.ProcessCommentParams calldata processCommentParams)
    external
    view
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
processCommentParamsTypes.ProcessCommentParamsThe parameters for processing a comment.

Returns

NameTypeDescription
<none>bytesbalance The ABI-encoded gate token balance of the profile trying to comment/quote/mirror.

processQuote

Processes a quote being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

Validates that the commenting profile's owner has enough balance of the gating token.

function processQuote(Types.ProcessQuoteParams calldata processQuoteParams)
    external
    view
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
processQuoteParamsTypes.ProcessQuoteParamsThe parameters for processing a quote.

Returns

NameTypeDescription
<none>bytesbalance The ABI-encoded gate token balance of the profile trying to comment/quote/mirror.

processMirror

Processes a mirror being published. This includes any module logic like transferring tokens, checking for conditions (e.g. token-gated), etc.

Validates that the mirroring profile's owner has enough balance of the gating token.

function processMirror(Types.ProcessMirrorParams calldata processMirrorParams)
    external
    view
    override
    onlyHub
    returns (bytes memory);

Parameters

NameTypeDescription
processMirrorParamsTypes.ProcessMirrorParamsThe parameters for processing a mirror.

Returns

NameTypeDescription
<none>bytesbalance The ABI-encoded gate token balance of the profile trying to comment/quote/mirror.

_validateTokenBalance

Validates the profile's owner balance of gating token. It can work with both ERC20 and ERC721 as both interfaces shares balanceOf function prototype.

function _validateTokenBalance(uint256 profileId, uint256 pointedProfileId, uint256 pointedPubId)
    internal
    view
    returns (uint256);

Parameters

NameTypeDescription
profileIduint256The ID of the profile trying to comment/quote/mirror.
pointedProfileIduint256The ID of the pointed publication's author.
pointedPubIduint256The ID of the pointed publication.

Returns

NameTypeDescription
<none>uint256uint256 The gate token balance of the profile trying to comment/quote/mirror.

Events

TokenGatedReferencePublicationCreated

event TokenGatedReferencePublicationCreated(
    uint256 indexed profileId, uint256 indexed pubId, address tokenAddress, uint256 minThreshold
);

Errors

NotEnoughBalance

error NotEnoughBalance();

ActionRestricted

Git Source

Author: Lens Protocol

This abstract contract adds a public ACTION_MODULE immutable field, and onlyActionModule modifier, to inherit from contracts that have functions restricted to be only called by the Action Modules.

State Variables

ACTION_MODULE

address public immutable ACTION_MODULE;

Functions

onlyActionModule

modifier onlyActionModule();

constructor

constructor(address actionModule);

FeeModuleBase

Git Source

Author: Lens Protocol

This is an abstract contract to be inherited from by modules that require basic fee functionality. It contains getters for module globals parameters as well as a validation function to check expected data.

State Variables

BPS_MAX

uint16 internal constant BPS_MAX = 10000;

HUB

ILensHub private immutable HUB;

MODULE_REGISTRY

IModuleRegistry public immutable MODULE_REGISTRY;

Functions

constructor

constructor(address hub);

_currencyWhitelisted

function _currencyWhitelisted(address currency) internal returns (bool);

_treasuryData

function _treasuryData() internal view returns (address, uint16);

_validateDataIsExpected

function _validateDataIsExpected(bytes calldata data, address currency, uint256 amount) internal pure;

Contents

Contents

RegistryErrors

Git Source

Errors

NotHandleNorTokenOwner

error NotHandleNorTokenOwner();

OnlyLensHub

error OnlyLensHub();

NotLinked

error NotLinked();

DoesNotExist

error DoesNotExist();

DoesNotHavePermissions

error DoesNotHavePermissions();

HandleAndTokenNotInSameWallet

error HandleAndTokenNotInSameWallet();

SignatureInvalid

error SignatureInvalid();

HandlesErrors

Git Source

Errors

HandleLengthInvalid

error HandleLengthInvalid();

HandleContainsInvalidCharacters

error HandleContainsInvalidCharacters();

HandleFirstCharInvalid

error HandleFirstCharInvalid();

NotOwnerNorWhitelisted

error NotOwnerNorWhitelisted();

NotOwner

error NotOwner();

NotHub

error NotHub();

DoesNotExist

error DoesNotExist();

NotEOA

error NotEOA();

DisablingAlreadyTriggered

error DisablingAlreadyTriggered();

GuardianEnabled

error GuardianEnabled();

AlreadyEnabled

error AlreadyEnabled();

HandlesEvents

Git Source

Events

HandleMinted

event HandleMinted(string handle, string namespace, uint256 handleId, address to, uint256 timestamp);

TokenGuardianStateChanged

Emitted when an address' Token Guardian state change is triggered.

event TokenGuardianStateChanged(
    address indexed wallet, bool indexed enabled, uint256 tokenGuardianDisablingTimestamp, uint256 timestamp
);

RegistryEvents

Git Source

Events

HandleLinked

event HandleLinked(
    RegistryTypes.Handle handle, RegistryTypes.Token token, address transactionExecutor, uint256 timestamp
);

HandleUnlinked

WARNING: If a linked handle or token is burnt, this event will not be emitted. Indexers should also take into account token burns through ERC-721 Transfer events to track all unlink actions. The resolveHandle and resolveToken functions will properly reflect the unlink in any case.

event HandleUnlinked(
    RegistryTypes.Handle handle, RegistryTypes.Token token, address transactionExecutor, uint256 timestamp
);

NonceUpdated

Emitted when a signer's nonce is used and, as a consequence, the next available nonce is updated.

event NonceUpdated(address indexed signer, uint256 nonce, uint256 timestamp);

Typehash

Git Source

State Variables

EIP712_DOMAIN

bytes32 constant EIP712_DOMAIN =
    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
bytes32 constant LINK = keccak256("Link(uint256 handleId,uint256 profileId,uint256 nonce,uint256 deadline)");
bytes32 constant UNLINK = keccak256("Unlink(uint256 handleId,uint256 profileId,uint256 nonce,uint256 deadline)");

RegistryTypes

Git Source

Author: Lens Protocol

Structs

Token

struct Token {
    uint256 id;
    address collection;
}

Handle

struct Handle {
    uint256 id;
    address collection;
}

LensHandles

Git Source

Inherits: ERC721, ImmutableOwnable, ILensHandles

A handle is defined as a local name inside a namespace context. A handle is represented as the local name with its namespace applied as a prefix, using the slash symbol as separator. handle = /${namespace}/${localName} Handle and local name can be used interchangeably once you are in a context of a namespace, as it became redundant. handle === ${localName} ; inside some namespace.

State Variables

MAX_LOCAL_NAME_LENGTH

uint256 internal constant MAX_LOCAL_NAME_LENGTH = 26;

NAMESPACE

string internal constant NAMESPACE = "lens";

NAMESPACE_LENGTH

uint256 internal immutable NAMESPACE_LENGTH = bytes(NAMESPACE).length;

SEPARATOR_LENGTH

uint256 internal constant SEPARATOR_LENGTH = 1;

NAMESPACE_HASH

bytes32 internal constant NAMESPACE_HASH = keccak256(bytes(NAMESPACE));

TOKEN_GUARDIAN_COOLDOWN

uint256 internal immutable TOKEN_GUARDIAN_COOLDOWN;

_tokenGuardianDisablingTimestamp

mapping(address => uint256) internal _tokenGuardianDisablingTimestamp;

_localNames

mapping(uint256 tokenId => string localName) internal _localNames;

Functions

onlyOwnerOrWhitelistedProfileCreator

modifier onlyOwnerOrWhitelistedProfileCreator();

onlyEOA

modifier onlyEOA();

onlyHub

modifier onlyHub();

constructor

constructor(address owner, address lensHub, uint256 tokenGuardianCooldown)
    ERC721("", "")
    ImmutableOwnable(owner, lensHub);

name

function name() public pure override returns (string memory);

symbol

function symbol() public pure override returns (string memory);

tokenURI

See {IERC721Metadata-tokenURI}.

function tokenURI(uint256 tokenId) public view override returns (string memory);

mintHandle

Mints a handle NFT in the given namespace.

function mintHandle(address to, string calldata localName)
    external
    onlyOwnerOrWhitelistedProfileCreator
    returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the handle to.
localNamestringThe local name of the handle (the part before ".lens").

Returns

NameTypeDescription
<none>uint256uint256 The ID of the handle NFT minted.

migrateHandle

function migrateHandle(address to, string calldata localName) external onlyHub returns (uint256);

burn

function burn(uint256 tokenId) external;

DANGER__disableTokenGuardian


**** TOKEN GUARDIAN FUNCTIONS ****


function DANGER__disableTokenGuardian() external onlyEOA;

enableTokenGuardian

function enableTokenGuardian() external onlyEOA;

approve

function approve(address to, uint256 tokenId) public override(IERC721, ERC721);

setApprovalForAll

function setApprovalForAll(address operator, bool approved) public override(IERC721, ERC721);

exists

function exists(uint256 tokenId) external view returns (bool);

getNamespace

function getNamespace() external pure returns (string memory);

getNamespaceHash

function getNamespaceHash() external pure returns (bytes32);

getLocalName

function getLocalName(uint256 tokenId) public view returns (string memory);

getHandle

function getHandle(uint256 tokenId) public view returns (string memory);

getTokenId

function getTokenId(string memory localName) public pure returns (uint256);

getTokenGuardianDisablingTimestamp

function getTokenGuardianDisablingTimestamp(address wallet) external view returns (uint256);

_mintHandle

INTERNAL FUNCTIONS ///

function _mintHandle(address to, string calldata localName) internal returns (uint256);

_validateLocalNameMigration

This function is used to validate the local name when migrating from V1 to V2. As in V1 we also allowed the Hyphen '-' character, we need to allow it here as well and use a separate validation function for migration VS newly created handles.

function _validateLocalNameMigration(string memory localName) internal pure;

_validateLocalName

In V2 we only accept the following characters: [a-z0-9_] to be used in newly created handles. We also disallow the first character to be an underscore '_'.

function _validateLocalName(string memory localName) internal pure;

_isAlphaNumeric

We only accept lowercase characters to avoid confusion.

function _isAlphaNumeric(bytes1 char) internal pure returns (bool);

Parameters

NameTypeDescription
charbytes1The character to check.

Returns

NameTypeDescription
<none>boolTrue if the character is alphanumeric, false otherwise.

_hasTokenGuardianEnabled

function _hasTokenGuardianEnabled(address wallet) internal view returns (bool);

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256, uint256 batchSize) internal override;

TokenHandleRegistry

Git Source

Inherits: ITokenHandleRegistry

Author: Lens Protocol

This contract is used to link a token with a handle.

State Variables

LENS_HUB

address immutable LENS_HUB;

LENS_HANDLES

address immutable LENS_HANDLES;

EIP1271_MAGIC_VALUE

bytes4 internal constant EIP1271_MAGIC_VALUE = 0x1626ba7e;

handleToToken

mapping(bytes32 handle => RegistryTypes.Token token) handleToToken;

tokenToHandle

mapping(bytes32 token => RegistryTypes.Handle handle) tokenToHandle;

nonces

mapping(address signer => uint256 nonce) public nonces;

Functions

constructor

constructor(address lensHub, address lensHandles);
function migrationLink(uint256 handleId, uint256 profileId) external;

Links a handle NFT with a profile NFT. Linking means a connection between the two NFTs is created, and the handle NFT can be used to resolve the profile NFT or vice versa.

*In the first version of the registry, the NFT contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one accepting addresses of the handle and token contracts.*
function link(uint256 handleId, uint256 profileId) external;

Parameters

NameTypeDescription
handleIduint256ID of the .lens namespace handle NFT
profileIduint256ID of the Lens Protocol Profile NFT

linkWithSig

function linkWithSig(uint256 handleId, uint256 profileId, Types.EIP712Signature calldata signature) external;
function _link(uint256 handleId, uint256 profileId, address transactionExecutor) private;

_validateLinkSignature

function _validateLinkSignature(Types.EIP712Signature calldata signature, uint256 handleId, uint256 profileId)
    internal;

_validateUnlinkSignature

function _validateUnlinkSignature(Types.EIP712Signature calldata signature, uint256 handleId, uint256 profileId)
    internal;

_validateRecoveredAddress

Wrapper for ecrecover to reduce code size, used in meta-tx specific functions.

function _validateRecoveredAddress(bytes32 digest, Types.EIP712Signature calldata signature) private view;

_calculateDigest

Calculates EIP712 digest based on the current DOMAIN_SEPARATOR.

function _calculateDigest(bytes32 hashedMessage) private view returns (bytes32);

Parameters

NameTypeDescription
hashedMessagebytes32The message hash from which the digest should be calculated.

Returns

NameTypeDescription
<none>bytes32bytes32 A 32-byte output representing the EIP712 digest.

calculateDomainSeparator

function calculateDomainSeparator() internal view returns (bytes32);

Unlinks a handle NFT from a profile NFT.

*In the first version of the registry, the contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one accepting addresses of the handle and token contracts.*
function unlink(uint256 handleId, uint256 profileId) external;

Parameters

NameTypeDescription
handleIduint256ID of the .lens namespace handle NFT
profileIduint256ID of the Lens Protocol Profile NFT

unlinkWithSig

function unlinkWithSig(uint256 handleId, uint256 profileId, Types.EIP712Signature calldata signature) external;
function _unlink(uint256 handleId, uint256 profileId, address transactionExecutor) private;

resolve

Resolves a handle NFT to a profile NFT.

*In the first version of the registry, the contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one.*
function resolve(uint256 handleId) external view returns (uint256);

Parameters

NameTypeDescription
handleIduint256ID of the .lens namespace handle NFT

Returns

NameTypeDescription
<none>uint256tokenId ID of the Lens Protocol Profile NFT

getDefaultHandle

Gets a default handle for a profile NFT (aka reverse resolution).

*In the first version of the registry, the contracts are hard-coded:

  • Handle is hard-coded to be of the .lens namespace
  • Token is hard-coded to be of the Lens Protocol Profile In future versions, the registry will be more flexible and allow for different namespaces and tokens, so this function might be deprecated and replaced with a new one.*
function getDefaultHandle(uint256 profileId) external view returns (uint256);

Parameters

NameTypeDescription
profileIduint256

Returns

NameTypeDescription
<none>uint256handleId ID of the .lens namespace handle NFT

_resolveHandleToToken

INTERNAL FUNCTIONS ///

function _resolveHandleToToken(RegistryTypes.Handle memory handle)
    internal
    view
    returns (RegistryTypes.Token storage);

_resolveTokenToHandle

function _resolveTokenToHandle(RegistryTypes.Token memory token) internal view returns (RegistryTypes.Handle storage);

_executeLinkage

function _executeLinkage(
    RegistryTypes.Handle memory handle,
    RegistryTypes.Token memory token,
    address transactionExecutor
) internal;

_deleteTokenToHandleLinkageIfAny

function _deleteTokenToHandleLinkageIfAny(RegistryTypes.Handle memory handle, address transactionExecutor) internal;

_deleteHandleToTokenLinkageIfAny

function _deleteHandleToTokenLinkageIfAny(RegistryTypes.Token memory token, address transactionExecutor) internal;

_executeUnlinkage

function _executeUnlinkage(
    RegistryTypes.Handle memory handle,
    RegistryTypes.Token memory token,
    address transactionExecutor
) internal;

_handleHash

function _handleHash(RegistryTypes.Handle memory handle) internal pure returns (bytes32);

_tokenHash

function _tokenHash(RegistryTypes.Token memory token) internal pure returns (bytes32);

_getNonceIncrementAndEmitEvent

This fetches a signer's current nonce and increments it so it's ready for the next meta-tx. Also emits the NonceUpdated event.

function _getNonceIncrementAndEmitEvent(address signer) private returns (uint256);

Parameters

NameTypeDescription
signeraddressThe address to get and increment the nonce for.

Returns

NameTypeDescription
<none>uint256uint256 The current nonce for the given signer prior to being incremented.

FollowNFT

Git Source

Inherits: HubRestricted, LensBaseERC721, ERC2981CollectionRoyalties, IFollowNFT

State Variables

FOLLOW_NFT_NAME_SUFFIX

string constant FOLLOW_NFT_NAME_SUFFIX = "-Follower";

FOLLOW_NFT_SYMBOL_SUFFIX

string constant FOLLOW_NFT_SYMBOL_SUFFIX = "-Fl";

___DEPRECATED_SLOTS

uint256[5] ___DEPRECATED_SLOTS;

_followedProfileId

uint256 internal _followedProfileId;

_lastFollowTokenId

uint128 internal _lastFollowTokenId;

_followerCount

uint128 internal _followerCount;

_initialized

bool private _initialized;

_followDataByFollowTokenId

mapping(uint256 => Types.FollowData) internal _followDataByFollowTokenId;

_followTokenIdByFollowerProfileId

mapping(uint256 => uint256) internal _followTokenIdByFollowerProfileId;

_followApprovalByFollowTokenId

mapping(uint256 => uint256) internal _followApprovalByFollowTokenId;

_royaltiesInBasisPoints

uint256 internal _royaltiesInBasisPoints;

Functions

whenNotPaused

modifier whenNotPaused();

constructor

constructor(address hub) HubRestricted(hub);

initialize

Initializes the follow NFT.

Sets the targeted profile, and the token royalties.

function initialize(uint256 profileId) external override;

Parameters

NameTypeDescription
profileIduint256The ID of the profile targeted by the follow tokens minted by this collection.

follow

Makes the passed profile follow the profile targeted in this contract.

function follow(uint256 followerProfileId, address transactionExecutor, uint256 followTokenId)
    external
    override
    onlyHub
    returns (uint256);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile acting as the follower.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).
followTokenIduint256The ID of the follow token to be used for this follow operation. Zero if a new follow token should be minted.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the token used to follow.

unfollow

Makes the passed profile unfollow the profile targeted in this contract.

function unfollow(uint256 unfollowerProfileId, address transactionExecutor) external override onlyHub;

Parameters

NameTypeDescription
unfollowerProfileIduint256The ID of the profile that is performing the unfollow operation.
transactionExecutoraddressThe address of the transaction executor (e.g. for any funds to transferFrom).

removeFollower

Removes the follower from the given follow NFT.

Only on wrapped token.

function removeFollower(uint256 followTokenId) external override whenNotPaused;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to remove the follower from.

approveFollow

Approves the given profile to follow with the given wrapped token.

Only on wrapped tokens. It approves setting a follower on the given wrapped follow token, which lets the follow token owner to allow a profile to follow with his token without losing its ownership. This approval is cleared on transfers, as well as when unwrapping.

function approveFollow(uint256 followerProfileId, uint256 followTokenId) external override;

Parameters

NameTypeDescription
followerProfileIduint256
followTokenIduint256The ID of the follow token to be approved for the given profile.

wrap

Unties the follow token from the follower's profile one, and wraps it into the ERC-721 untied follow tokens collection. Untied follow tokens will NOT be automatically transferred with their follower profile.

Only on unwrapped follow tokens.

function wrap(uint256 followTokenId, address wrappedTokenReceiver) external override whenNotPaused;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to untie and wrap.
wrappedTokenReceiveraddress

wrap

Unties the follow token from the follower's profile one, and wraps it into the ERC-721 untied follow tokens collection. Untied follow tokens will NOT be automatically transferred with their follower profile.

Only on unwrapped follow tokens.

function wrap(uint256 followTokenId) external override whenNotPaused;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to untie and wrap.

_wrap

function _wrap(uint256 followTokenId, address wrappedTokenReceiver) internal;

unwrap

Unwraps the follow token from the ERC-721 untied follow tokens collection, and ties it to the follower's profile token. Tokens that are tied to the follower profile will be automatically transferred with it.

function unwrap(uint256 followTokenId) external override whenNotPaused;

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token to unwrap and tie to its follower.

processBlock

Processes logic when the given profile is being blocked. If it was following the targeted profile, this will make it unfollow.

function processBlock(uint256 followerProfileId) external override onlyHub returns (bool);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the follow token to unwrap and tie.

Returns

NameTypeDescription
<none>boolbool True if the given profile was following and now has unfollowed, false otherwise.

getFollowerProfileId

GETTERS ///

function getFollowerProfileId(uint256 followTokenId) external view override returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose follower should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the profile following with the given token, zero if it is not being used to follow.

isFollowing

Tells if the given profile is following the profile targeted in this contract.

function isFollowing(uint256 followerProfileId) external view override returns (bool);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile whose following state should be queried.

Returns

NameTypeDescription
<none>booluint256 The ID of the profile set as a follower in the given token, zero if it is not being used to follow.

getFollowTokenId

Gets the ID of the token being used to follow by the given follower.

function getFollowTokenId(uint256 followerProfileId) external view override returns (uint256);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile whose follow ID should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the token being used to follow by the given follower, zero if he is not following.

getOriginalFollowTimestamp

Gets the original follow timestamp of the given follow token.

function getOriginalFollowTimestamp(uint256 followTokenId) external view override returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose original follow timestamp should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The timestamp of the first follow performed with the token, zero if was not used to follow yet.

getFollowTimestamp

Gets the current follow timestamp of the given follow token.

function getFollowTimestamp(uint256 followTokenId) external view override returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose follow timestamp should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The timestamp of the current follow of the token, zero if it is not being used to follow.

getProfileIdAllowedToRecover

Gets the ID of the profile allowed to recover the given follow token.

function getProfileIdAllowedToRecover(uint256 followTokenId) external view override returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose allowed profile to recover should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the profile allowed to recover the given follow token, zero if none of them is allowed.

getFollowData

Gets the follow data of the given follow token.

function getFollowData(uint256 followTokenId) external view override returns (Types.FollowData memory);

Parameters

NameTypeDescription
followTokenIduint256The ID of the follow token whose follow data should be queried.

Returns

NameTypeDescription
<none>Types.FollowDataFollowData The token data associated with the given follow token.

getFollowApproved

Gets the ID of the profile approved to follow with the given token.

function getFollowApproved(uint256 followTokenId) external view override returns (uint256);

Parameters

NameTypeDescription
followTokenIduint256The ID of the token whose approved to follow should be queried.

Returns

NameTypeDescription
<none>uint256uint256 The ID of the profile approved to follow with the given token, zero if none of them is approved.

getFollowerCount

Gets the count of the followers of the profile targeted in this contract.

function getFollowerCount() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The count of the followers of the profile targeted in this contract.

burn

function burn(uint256 followTokenId) public override whenNotPaused;

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(LensBaseERC721, ERC2981CollectionRoyalties)
    returns (bool);

name

function name() public view override returns (string memory);

symbol

function symbol() public view override returns (string memory);

tokenURI

This returns the follow NFT URI fetched from the hub.

function tokenURI(uint256 followTokenId) public view override returns (string memory);

_followMintingNewToken

function _followMintingNewToken(uint256 followerProfileId) internal returns (uint256);

_followWithWrappedToken

function _followWithWrappedToken(uint256 followerProfileId, address transactionExecutor, uint256 followTokenId)
    internal
    returns (uint256);

_followWithUnwrappedTokenFromBurnedProfile

function _followWithUnwrappedTokenFromBurnedProfile(
    uint256 followerProfileId,
    uint256 followTokenId,
    uint256 currentFollowerProfileId,
    address transactionExecutor
) internal returns (uint256);

_followByRecoveringToken

function _followByRecoveringToken(uint256 followerProfileId, uint256 followTokenId) internal returns (uint256);

_replaceFollower

function _replaceFollower(
    uint256 currentFollowerProfileId,
    uint256 newFollowerProfileId,
    uint256 followTokenId,
    address transactionExecutor
) internal;

_baseFollow

function _baseFollow(uint256 followerProfileId, uint256 followTokenId, bool isOriginalFollow) internal;

_unfollowIfHasFollower

function _unfollowIfHasFollower(uint256 followTokenId, address transactionExecutor) internal;

_unfollow

function _unfollow(uint256 unfollower, uint256 followTokenId) internal;

_approveFollow

function _approveFollow(uint256 approvedProfileId, uint256 followTokenId) internal;

_beforeTokenTransfer

Upon transfers, we clear follow approvals and emit the transfer event in the hub.

function _beforeTokenTransfer(address from, address to, uint256 followTokenId) internal override whenNotPaused;

_getReceiver

function _getReceiver(uint256) internal view override returns (address);

_beforeRoyaltiesSet

function _beforeRoyaltiesSet(uint256) internal view override;

_isFollowTokenWrapped

function _isFollowTokenWrapped(uint256 followTokenId) internal view returns (bool);

_getRoyaltiesInBasisPointsSlot

function _getRoyaltiesInBasisPointsSlot() internal pure override returns (uint256);

tryMigrate

Migrations ///

function tryMigrate(uint256 followerProfileId, address followerProfileOwner, uint256 followTokenId)
    external
    onlyHub
    returns (uint48);

Events

FollowApproval

event FollowApproval(uint256 indexed followerProfileId, uint256 indexed followTokenId);

LensHub

Git Source

Inherits: LensProfiles, LensGovernable, LensV2Migration, LensImplGetters, LensHubEventHooks, LensHubStorage, ILensProtocol

Author: Lens Protocol

This is the main entry point of the Lens Protocol. It contains governance functionality as well as publishing and profile interaction functionality. NOTE: The Lens Protocol is unique in that frontend operators need to track a potentially overwhelming number of NFT contracts and interactions at once. For that reason, we've made two quirky design decisions:

  1. Both Follow & Collect NFTs invoke a LensHub callback on transfer with the sole purpose of emitting an event.
  2. Almost every event in the protocol emits the current block timestamp, reducing the need to fetch it manually.

Functions

onlyProfileOwnerOrDelegatedExecutor

modifier onlyProfileOwnerOrDelegatedExecutor(address expectedOwnerOrDelegatedExecutor, uint256 profileId);

whenPublishingEnabled

modifier whenPublishingEnabled();

constructor

constructor(
    address followNFTImpl,
    address legacyCollectNFTImpl,
    address moduleRegistry,
    uint256 tokenGuardianCooldown,
    Types.MigrationParams memory migrationParams
)
    LensV2Migration(migrationParams)
    LensProfiles(tokenGuardianCooldown)
    LensImplGetters(followNFTImpl, legacyCollectNFTImpl, moduleRegistry);

createProfile

Creates a profile with the specified parameters, minting a Profile NFT to the given recipient.

function createProfile(Types.CreateProfileParams calldata createProfileParams)
    external
    override
    whenNotPaused
    returns (uint256);

Parameters

NameTypeDescription
createProfileParamsTypes.CreateProfileParamsA CreateProfileParams struct containing the needed params.

setProfileMetadataURI

PROFILE OWNER FUNCTIONS ///

function setProfileMetadataURI(uint256 profileId, string calldata metadataURI)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, profileId);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to set the metadata URI for.
metadataURIstringThe metadata URI to set for the given profile.

setProfileMetadataURIWithSig

function setProfileMetadataURIWithSig(
    uint256 profileId,
    string calldata metadataURI,
    Types.EIP712Signature calldata signature
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, profileId);

setFollowModule

Sets the follow module for the given profile.

function setFollowModule(uint256 profileId, address followModule, bytes calldata followModuleInitData)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, profileId);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to set the follow module for.
followModuleaddressThe follow module to set for the given profile, must be whitelisted.
followModuleInitDatabytesThe data to be passed to the follow module for initialization.

setFollowModuleWithSig

function setFollowModuleWithSig(
    uint256 profileId,
    address followModule,
    bytes calldata followModuleInitData,
    Types.EIP712Signature calldata signature
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, profileId);

changeDelegatedExecutorsConfig

Changes the delegated executors configuration for the given profile. It allows setting the approvals for delegated executors in the specified configuration, as well as switching to it.

function changeDelegatedExecutorsConfig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals,
    uint64 configNumber,
    bool switchToGivenConfig
) external override whenNotPaused onlyProfileOwner(msg.sender, delegatorProfileId);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile to which the delegated executor is being changed for.
delegatedExecutorsaddress[]The array of delegated executors to set the approval for.
approvalsbool[]The array of booleans indicating the corresponding executor's new approval status.
configNumberuint64The number of the configuration where the executor approval state is being set.
switchToGivenConfigboolA boolean indicating if the configuration must be switched to the one with the given number.

changeDelegatedExecutorsConfig

function changeDelegatedExecutorsConfig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals
) external override whenNotPaused onlyProfileOwner(msg.sender, delegatorProfileId);

changeDelegatedExecutorsConfigWithSig

function changeDelegatedExecutorsConfigWithSig(
    uint256 delegatorProfileId,
    address[] calldata delegatedExecutors,
    bool[] calldata approvals,
    uint64 configNumber,
    bool switchToGivenConfig,
    Types.EIP712Signature calldata signature
) external override whenNotPaused onlyProfileOwner(signature.signer, delegatorProfileId);

post

PUBLISHING FUNCTIONS ///

function post(Types.PostParams calldata postParams)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, postParams.profileId)
    returns (uint256);

Parameters

NameTypeDescription
postParamsTypes.PostParamsA PostParams struct containing the needed parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the post's publication ID.

postWithSig

function postWithSig(Types.PostParams calldata postParams, Types.EIP712Signature calldata signature)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(signature.signer, postParams.profileId)
    returns (uint256);

comment

Publishes a comment on the given publication. Comment is a type of reference publication that points to another publication. Comments can have these types of modules initialized:

  • Action modules: any number of publication actions (e.g. collect, tip, etc.)
  • Reference module: a module handling the rules when referencing this comment (e.g. token-gated mirrors) Comments can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).
function comment(Types.CommentParams calldata commentParams)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, commentParams.profileId)
    returns (uint256);

Parameters

NameTypeDescription
commentParamsTypes.CommentParamsA CommentParams struct containing the needed parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the comment's publication ID.

commentWithSig

function commentWithSig(Types.CommentParams calldata commentParams, Types.EIP712Signature calldata signature)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(signature.signer, commentParams.profileId)
    returns (uint256);

mirror

Publishes a mirror of the given publication. Mirror is a type of reference publication that points to another publication but doesn't have content. Mirrors don't have any modules initialized. Mirrors can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). You cannot mirror a mirror, comment on a mirror, or quote a mirror.

function mirror(Types.MirrorParams calldata mirrorParams)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, mirrorParams.profileId)
    returns (uint256);

Parameters

NameTypeDescription
mirrorParamsTypes.MirrorParamsA MirrorParams struct containing the necessary parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the mirror's publication ID.

mirrorWithSig

function mirrorWithSig(Types.MirrorParams calldata mirrorParams, Types.EIP712Signature calldata signature)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(signature.signer, mirrorParams.profileId)
    returns (uint256);

quote

Publishes a quote of the given publication. Quote is a type of reference publication similar to mirror, but it has content and modules. Quotes can have these types of modules initialized:

  • Action modules: any number of publication actions (e.g. collect, tip, etc.)
  • Reference module: a module handling the rules when referencing this quote (e.g. token-gated comments on quote) Quotes can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). Unlike mirrors, you can mirror a quote, comment on a quote, or quote a quote.
function quote(Types.QuoteParams calldata quoteParams)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, quoteParams.profileId)
    returns (uint256);

Parameters

NameTypeDescription
quoteParamsTypes.QuoteParamsA QuoteParams struct containing the needed parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the quote's publication ID.

quoteWithSig

function quoteWithSig(Types.QuoteParams calldata quoteParams, Types.EIP712Signature calldata signature)
    external
    override
    whenPublishingEnabled
    onlyProfileOwnerOrDelegatedExecutor(signature.signer, quoteParams.profileId)
    returns (uint256);

follow

PROFILE INTERACTION FUNCTIONS ///

Both the idsOfProfilesToFollow, followTokenIds, and datas arrays must be of the same length, regardless if the profiles do not have a follow module set.

function follow(
    uint256 followerProfileId,
    uint256[] calldata idsOfProfilesToFollow,
    uint256[] calldata followTokenIds,
    bytes[] calldata datas
)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, followerProfileId)
    returns (uint256[] memory);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile the follows are being executed for.
idsOfProfilesToFollowuint256[]The array of IDs of profiles to follow.
followTokenIdsuint256[]The array of follow token IDs to use for each follow (0 if you don't own a follow token).
datasbytes[]The arbitrary data array to pass to the follow module for each profile if needed.

Returns

NameTypeDescription
<none>uint256[]uint256[] An array of follow token IDs representing the follow tokens created for each follow.

followWithSig

function followWithSig(
    uint256 followerProfileId,
    uint256[] calldata idsOfProfilesToFollow,
    uint256[] calldata followTokenIds,
    bytes[] calldata datas,
    Types.EIP712Signature calldata signature
)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(signature.signer, followerProfileId)
    returns (uint256[] memory);

unfollow

Unfollows given profiles.

function unfollow(uint256 unfollowerProfileId, uint256[] calldata idsOfProfilesToUnfollow)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, unfollowerProfileId);

Parameters

NameTypeDescription
unfollowerProfileIduint256The ID of the profile the unfollows are being executed for.
idsOfProfilesToUnfollowuint256[]The array of IDs of profiles to unfollow.

unfollowWithSig

function unfollowWithSig(
    uint256 unfollowerProfileId,
    uint256[] calldata idsOfProfilesToUnfollow,
    Types.EIP712Signature calldata signature
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, unfollowerProfileId);

setBlockStatus

Sets the block status for the given profiles. Changing a profile's block status to true (i.e. blocked), when will also force them to unfollow. Blocked profiles cannot perform any actions with the profile that blocked them: they cannot comment or mirror their publications, they cannot follow them, they cannot collect, tip them, etc.

Both the idsOfProfilesToSetBlockStatus and blockStatus arrays must be of the same length.

function setBlockStatus(
    uint256 byProfileId,
    uint256[] calldata idsOfProfilesToSetBlockStatus,
    bool[] calldata blockStatus
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(msg.sender, byProfileId);

Parameters

NameTypeDescription
byProfileIduint256The ID of the profile that is blocking/unblocking somebody.
idsOfProfilesToSetBlockStatusuint256[]The array of IDs of profiles to set block status.
blockStatusbool[]The array of block statuses to use for each (true is blocked).

setBlockStatusWithSig

function setBlockStatusWithSig(
    uint256 byProfileId,
    uint256[] calldata idsOfProfilesToSetBlockStatus,
    bool[] calldata blockStatus,
    Types.EIP712Signature calldata signature
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, byProfileId);

collectLegacy

Collects a given publication via signature with the specified parameters. Collect can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).

function collectLegacy(Types.LegacyCollectParams calldata collectParams)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, collectParams.collectorProfileId)
    returns (uint256);

Parameters

NameTypeDescription
collectParamsTypes.LegacyCollectParamsA CollectParams struct containing the parameters.

Returns

NameTypeDescription
<none>uint256uint256 An integer representing the minted token ID.

collectLegacyWithSig

function collectLegacyWithSig(
    Types.LegacyCollectParams calldata collectParams,
    Types.EIP712Signature calldata signature
)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(signature.signer, collectParams.collectorProfileId)
    returns (uint256);

act

Acts on a given publication with the specified parameters. You can act on a publication except a mirror (if it has at least one action module initialized). Actions can have referrers (e.g. publications or profiles that allowed to discover the pointed publication).

function act(Types.PublicationActionParams calldata publicationActionParams)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(msg.sender, publicationActionParams.actorProfileId)
    returns (bytes memory);

Parameters

NameTypeDescription
publicationActionParamsTypes.PublicationActionParamsA PublicationActionParams struct containing the parameters.

Returns

NameTypeDescription
<none>bytesbytes Arbitrary data the action module returns.

actWithSig

function actWithSig(
    Types.PublicationActionParams calldata publicationActionParams,
    Types.EIP712Signature calldata signature
)
    external
    override
    whenNotPaused
    onlyProfileOwnerOrDelegatedExecutor(signature.signer, publicationActionParams.actorProfileId)
    returns (bytes memory);

isFollowing

EXTERNAL VIEW FUNCTIONS ///

function isFollowing(uint256 followerProfileId, uint256 followedProfileId) external view returns (bool);

Parameters

NameTypeDescription
followerProfileIduint256The ID of the profile whose following state should be queried.
followedProfileIduint256The ID of the profile whose followed state should be queried.

Returns

NameTypeDescription
<none>boolbool True if followerProfileId is following followedProfileId, false otherwise.

isDelegatedExecutorApproved

Returns whether the given address is approved as delegated executor, in the configuration with the given number, to act on behalf of the given profile.

function isDelegatedExecutorApproved(uint256 delegatorProfileId, address delegatedExecutor, uint64 configNumber)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile to check the delegated executor approval for.
delegatedExecutoraddressThe address to query the delegated executor approval for.
configNumberuint64The number of the configuration where the executor approval state is being queried.

Returns

NameTypeDescription
<none>boolbool True if the address is approved as a delegated executor to act on behalf of the profile in the given configuration, false otherwise.

isDelegatedExecutorApproved

Returns whether the given address is approved as delegated executor, in the configuration with the given number, to act on behalf of the given profile.

function isDelegatedExecutorApproved(uint256 delegatorProfileId, address delegatedExecutor)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile to check the delegated executor approval for.
delegatedExecutoraddressThe address to query the delegated executor approval for.

Returns

NameTypeDescription
<none>boolbool True if the address is approved as a delegated executor to act on behalf of the profile in the given configuration, false otherwise.

getDelegatedExecutorsConfigNumber

Returns the current delegated executor config number for the given profile.

function getDelegatedExecutorsConfigNumber(uint256 delegatorProfileId) external view returns (uint64);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile from which the delegated executors config number is being queried

Returns

NameTypeDescription
<none>uint64uint256 The current delegated executor configuration number.

getDelegatedExecutorsPrevConfigNumber

Returns the previous used delegated executor config number for the given profile.

function getDelegatedExecutorsPrevConfigNumber(uint256 delegatorProfileId) external view returns (uint64);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile from which the delegated executors' previous configuration number set is being queried.

Returns

NameTypeDescription
<none>uint64uint256 The delegated executor configuration number previously set. It will coincide with the current configuration set if it was never switched from the default one.

getDelegatedExecutorsMaxConfigNumberSet

Returns the maximum delegated executor config number for the given profile. This is the maximum config number that was ever used by this profile. When creating a new clean configuration, you can only use a number that is maxConfigNumber + 1.

function getDelegatedExecutorsMaxConfigNumberSet(uint256 delegatorProfileId) external view returns (uint64);

Parameters

NameTypeDescription
delegatorProfileIduint256The ID of the profile from which the delegated executors' maximum configuration number set is being queried.

Returns

NameTypeDescription
<none>uint64uint256 The delegated executor maximum configuration number set.

isBlocked

Returns whether profileId is blocked by byProfileId. See setBlockStatus() for more information on how blocking works on the platform.

function isBlocked(uint256 profileId, uint256 byProfileId) external view returns (bool);

Parameters

NameTypeDescription
profileIduint256The ID of the profile whose blocked status should be queried.
byProfileIduint256The ID of the profile whose blocker status should be queried.

Returns

NameTypeDescription
<none>boolbool True if profileId is blocked by byProfileId, false otherwise.

getContentURI

Returns the URI associated with a given publication. This is used to store the publication's metadata, e.g.: content, images, etc.

function getContentURI(uint256 profileId, uint256 pubId) external view override returns (string memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>stringstring The URI associated with a given publication.

getProfile

Returns the full profile struct associated with a given profile token ID.

function getProfile(uint256 profileId) external view override returns (Types.Profile memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile to query.

Returns

NameTypeDescription
<none>Types.ProfileProfile The profile struct of the given profile.

getPublication

Returns the full publication struct for a given publication.

function getPublication(uint256 profileId, uint256 pubId)
    external
    pure
    override
    returns (Types.PublicationMemory memory);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>Types.PublicationMemoryPublication The publication struct associated with the queried publication.

isActionModuleEnabledInPublication

Returns wether a given Action Module is enabled for a given publication.

function isActionModuleEnabledInPublication(uint256 profileId, uint256 pubId, address module)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.
moduleaddressThe address of the Action Module to query.

Returns

NameTypeDescription
<none>boolbool True if the Action Module is enabled for the queried publication, false if not.

getPublicationType

Returns the type of a given publication. The type can be one of the following (see PublicationType enum):

  • Nonexistent
  • Post
  • Comment
  • Mirror
  • Quote
function getPublicationType(uint256 profileId, uint256 pubId) external view override returns (Types.PublicationType);

Parameters

NameTypeDescription
profileIduint256The token ID of the profile that published the publication to query.
pubIduint256The publication ID of the publication to query.

Returns

NameTypeDescription
<none>Types.PublicationTypePublicationType The publication type of the queried publication.