Post
Share your knowledge.
`collectModuleInitData` in lens protocol
In Lens if I want to create a publication, I need the following inputs:
uint256 profileId;
string contentURI;
address collectModule;
bytes collectModuleInitData;
address referenceModule;
bytes referenceModuleInitData;
- profileId: Your profile ID.
- You can find this by calling
getProfileByHandleon the main contract. For examplepatrickalphac.lensreturns34460
- You can find this by calling
- contentURI: This will be your content URI, like what you see for an NFT. For example.
- collectModule: The address of the collection contract you want. I want my stuff to be free to collect, so I'll use
0x23b9467334bEb345aAa6fd1545538F3d54436e96. - collectModuleInitData: ??
- referenceModule: The module (contract) that governs who can reference your content. For example
0x0000000000000000000000000000000000000000. (Meaning anyone can reference) - referenceModuleInitData: ??
How do we know what data we would need to pass? What function is going to be called on the collectModule?
There are some functions in the collect module contract:
/**
* @dev There is nothing needed at initialization.
*/
function initializePublicationCollectModule(
uint256 profileId,
uint256 pubId,
bytes calldata data
) external override onlyHub returns (bytes memory) {
bool followerOnly = abi.decode(data, (bool));
if (followerOnly) _followerOnlyByPublicationByProfile[profileId][pubId] = true;
return data;
}
/**
* @dev Processes a collect by:
* 1. Ensuring the collector is a follower, if needed
*/
function processCollect(
uint256 referrerProfileId,
address collector,
uint256 profileId,
uint256 pubId,
bytes calldata data
) external view override {
if (_followerOnlyByPublicationByProfile[profileId][pubId])
_checkFollowValidity(profileId, collector);
}
Am I having the data be for one of these function?
- blockchain
Answers
2Each module will have their own requirements on what data you need to pass.
For each function like:
function initializePublicationCollectModule(
uint256 profileId,
uint256 pubId,
bytes calldata data
)
The data field is where your data will go.
For the default free collect module, you need to pass a true value (0x00...1) for it to work.
As far as I can tell, it is for initializePublicationCollectModule function call.
Posts are created with post function of LensHub contract. This function calls into PublishingLogic contract's function createPost. From there it calls _initPubCollectModule where you can see the call to initializePublicationCollectModule.
Do you know the answer?
Please log in and share it.
Web3 (also known as Web 3.0) is an idea for a new iteration of the World Wide Web which incorporates concepts such as decentralization, blockchain technologies, and token-based economics.