Laika for Lens
Digging into Lens Protocol with ease using Laika
Last updated
Digging into Lens Protocol with ease using Laika
Last updated
A lot of you might have heard about Lens Protocol. It’s a new Web3 social graph protocol built by the Aave team. To solve a lot of significant issues in social media that we are currently using in our web2 based lives.
For more details about Lens Protocol you can check out their documentation at https://docs.lens.xyz/docs/what-is-lens
Introduction
The Lens Protocol is a Web3 social graph on the Polygon Proof-of-Stake blockchain. It is designed to empower creators to own the links between themselves and their community, forming a fully composable, user-owned social graph. The protocol is built from the ground up with modularity in mind, allowing new features and fixes to be added while ensuring immutable user-owned content and social relationships.
This article aims to be a small helper in which we’re going to explore how we can use Laika to interact with Lens Protocol!
What we’re going to do
We are going to explore Lens Protocol on Polygon Mumbai Testnet
Create our own Lens Handle (xxx.lens) through MockProfileCreationProxy contract
Create a new post on Lens through LensHub Proxy
The team at Lens Protocol designed it to be modular. this is so it is easy to scale the community of Lens Protocol itself. Lens Protocol tokenizes a lot of functionality into ERC721-compliant. So if someone wanted to add more features to Lens Protocol. They just write a new module and then plug it into it. Simple as that!
The smart contract that you’ll be going to interact with a lot is called “Lens Hub”. This is where Lens Protocol places the entry point for the majority of interactions with its protocol.
For the list of contracts deployed on each chain you can look for it here: https://docs.lens.xyz/docs/deployed-contract-addresses
Before beginning with anything make sure you have MATIC in your wallet on Mumbai Testnet. You can request tokens here https://faucet.polygon.technology/
To create a Lens Profile on Polygon Mumbai is using a little bit different way than other interactions. As I wrote above that you’ll have to interact with Lens Hub. Well, this is not the case haha.
Lens Protocol has a whitelist of people who could create a Lens Profile. Typically, Our address is not in there. But we could create Lens Profile by creating it through the MockProfileCreationProxy contract. Which is going to be a proxy that gave us permission to create a new Profile.
For Polygon Mumbai MockProfileCreationProxy is deployed at 0x420f0257D43145bb002E69B14FF2Eb9630Fc4736
Alright! Let’s do it then.
To make it easier for you guys to follow this tutorial. I exported collections that we’re going to use in this article. You can download it from gist here.
{"name":"Exploring Lens Protocol","children":[{"name":"MockProfileCreatorProxy","children":[{"lock":false,"address":"{{MOCK_PROFILE_CREATOR_PROXY}}","name":"proxyCreateProfile","abi":{"inputs":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"string","name":"handle","type":"string"},{"internalType":"string","name":"imageURI","type":"string"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bytes","name":"followModuleInitData","type":"bytes"},{"internalType":"string","name":"followNFTURI","type":"string"}],"internalType":"struct DataTypes.CreateProfileData","name":"vars","type":"tuple"}],"name":"proxyCreateProfile","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[[]]}],"lock":false},{"name":"LensHub","children":[{"lock":true,"address":"{{LENS_HUB}}","name":"whitelistReferenceModule","abi":{"inputs":[{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistReferenceModule","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"whitelistProfileCreator","abi":{"inputs":[{"internalType":"address","name":"profileCreator","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistProfileCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"whitelistFollowModule","abi":{"inputs":[{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistFollowModule","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"whitelistCollectModule","abi":{"inputs":[{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistCollectModule","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"transferFrom","abi":{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"totalSupply","abi":{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"tokenURI","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"tokenOfOwnerByIndex","abi":{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"tokenDataOf","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenDataOf","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint96","name":"mintTimestamp","type":"uint96"}],"internalType":"struct IERC721Time.TokenData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"tokenByIndex","abi":{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"symbol","abi":{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"supportsInterface","abi":{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"sigNonces","abi":{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"sigNonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setState","abi":{"inputs":[{"internalType":"enum DataTypes.ProtocolState","name":"newState","type":"uint8"}],"name":"setState","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setProfileImageURIWithSig","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"imageURI","type":"string"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetProfileImageURIWithSigData","name":"vars","type":"tuple"}],"name":"setProfileImageURIWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setProfileImageURI","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"imageURI","type":"string"}],"name":"setProfileImageURI","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setGovernance","abi":{"inputs":[{"internalType":"address","name":"newGovernance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setFollowNFTURIWithSig","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"followNFTURI","type":"string"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetFollowNFTURIWithSigData","name":"vars","type":"tuple"}],"name":"setFollowNFTURIWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setFollowNFTURI","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"followNFTURI","type":"string"}],"name":"setFollowNFTURI","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setFollowModuleWithSig","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bytes","name":"followModuleInitData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetFollowModuleWithSigData","name":"vars","type":"tuple"}],"name":"setFollowModuleWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setFollowModule","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bytes","name":"followModuleInitData","type":"bytes"}],"name":"setFollowModule","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setEmergencyAdmin","abi":{"inputs":[{"internalType":"address","name":"newEmergencyAdmin","type":"address"}],"name":"setEmergencyAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setDispatcherWithSig","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"address","name":"dispatcher","type":"address"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetDispatcherWithSigData","name":"vars","type":"tuple"}],"name":"setDispatcherWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setDispatcher","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"address","name":"dispatcher","type":"address"}],"name":"setDispatcher","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setDefaultProfileWithSig","abi":{"inputs":[{"components":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"uint256","name":"profileId","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetDefaultProfileWithSigData","name":"vars","type":"tuple"}],"name":"setDefaultProfileWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setDefaultProfile","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"setDefaultProfile","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"setApprovalForAll","abi":{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"safeTransferFrom","abi":{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"safeTransferFrom","abi":{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"postWithSig","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleInitData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleInitData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.PostWithSigData","name":"vars","type":"tuple"}],"name":"postWithSig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"post","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleInitData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleInitData","type":"bytes"}],"internalType":"struct DataTypes.PostData","name":"vars","type":"tuple"}],"name":"post","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"permitForAll","abi":{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"name":"permitForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"permit","abi":{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"ownerOf","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"name","abi":{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"mirrorWithSig","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleInitData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.MirrorWithSigData","name":"vars","type":"tuple"}],"name":"mirrorWithSig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"mirror","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleInitData","type":"bytes"}],"internalType":"struct DataTypes.MirrorData","name":"vars","type":"tuple"}],"name":"mirror","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"mintTimestampOf","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"mintTimestampOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"isReferenceModuleWhitelisted","abi":{"inputs":[{"internalType":"address","name":"referenceModule","type":"address"}],"name":"isReferenceModuleWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"isProfileCreatorWhitelisted","abi":{"inputs":[{"internalType":"address","name":"profileCreator","type":"address"}],"name":"isProfileCreatorWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"isFollowModuleWhitelisted","abi":{"inputs":[{"internalType":"address","name":"followModule","type":"address"}],"name":"isFollowModuleWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"isCollectModuleWhitelisted","abi":{"inputs":[{"internalType":"address","name":"collectModule","type":"address"}],"name":"isCollectModuleWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"isApprovedForAll","abi":{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"initialize","abi":{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"newGovernance","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getState","abi":{"inputs":[],"name":"getState","outputs":[{"internalType":"enum DataTypes.ProtocolState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"getReferenceModule","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getReferenceModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getPubType","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getPubType","outputs":[{"internalType":"enum DataTypes.PubType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getPubPointer","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getPubPointer","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getPubCount","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getPubCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getPub","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getPub","outputs":[{"components":[{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"address","name":"collectNFT","type":"address"}],"internalType":"struct DataTypes.PublicationStruct","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getProfileIdByHandle","abi":{"inputs":[{"internalType":"string","name":"handle","type":"string"}],"name":"getProfileIdByHandle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getProfile","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getProfile","outputs":[{"components":[{"internalType":"uint256","name":"pubCount","type":"uint256"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"address","name":"followNFT","type":"address"},{"internalType":"string","name":"handle","type":"string"},{"internalType":"string","name":"imageURI","type":"string"},{"internalType":"string","name":"followNFTURI","type":"string"}],"internalType":"struct DataTypes.ProfileStruct","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getHandle","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getHandle","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getGovernance","abi":{"inputs":[],"name":"getGovernance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"getFollowNFTURI","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getFollowNFTURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getFollowNFTImpl","abi":{"inputs":[],"name":"getFollowNFTImpl","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"getFollowNFT","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getFollowNFT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getFollowModule","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getFollowModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getDomainSeparator","abi":{"inputs":[],"name":"getDomainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"getDispatcher","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getDispatcher","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getContentURI","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getContentURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getCollectNFTImpl","abi":{"inputs":[],"name":"getCollectNFTImpl","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[]},{"lock":true,"address":"{{LENS_HUB}}","name":"getCollectNFT","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getCollectNFT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getCollectModule","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getCollectModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"getApproved","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"followWithSig","abi":{"inputs":[{"components":[{"internalType":"address","name":"follower","type":"address"},{"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"internalType":"bytes[]","name":"datas","type":"bytes[]"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.FollowWithSigData","name":"vars","type":"tuple"}],"name":"followWithSig","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"follow","abi":{"inputs":[{"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"internalType":"bytes[]","name":"datas","type":"bytes[]"}],"name":"follow","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},"params":[[],[]]},{"lock":true,"address":"{{LENS_HUB}}","name":"exists","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"emitFollowNFTTransferEvent","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"followNFTId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"emitFollowNFTTransferEvent","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"emitCollectNFTTransferEvent","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"uint256","name":"collectNFTId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"emitCollectNFTTransferEvent","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["","","","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"defaultProfile","abi":{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"defaultProfile","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"createProfile","abi":{"inputs":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"string","name":"handle","type":"string"},{"internalType":"string","name":"imageURI","type":"string"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bytes","name":"followModuleInitData","type":"bytes"},{"internalType":"string","name":"followNFTURI","type":"string"}],"internalType":"struct DataTypes.CreateProfileData","name":"vars","type":"tuple"}],"name":"createProfile","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"commentWithSig","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleInitData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleInitData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.CommentWithSigData","name":"vars","type":"tuple"}],"name":"commentWithSig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"comment","abi":{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleInitData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleInitData","type":"bytes"}],"internalType":"struct DataTypes.CommentData","name":"vars","type":"tuple"}],"name":"comment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"collectWithSig","abi":{"inputs":[{"components":[{"internalType":"address","name":"collector","type":"address"},{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.CollectWithSigData","name":"vars","type":"tuple"}],"name":"collectWithSig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"collect","abi":{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"collect","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},"params":["","",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"burnWithSig","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"name":"burnWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":["",""]},{"lock":true,"address":"{{LENS_HUB}}","name":"burn","abi":{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"balanceOf","abi":{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},"params":[""]},{"lock":true,"address":"{{LENS_HUB}}","name":"approve","abi":{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayabnle","type":"function"},"params":["",""]}]}],"lock":false,"version":1}
Then open Laika at web.getlaika.app Click on Import Collection. Then drop in the JSON file you just downloaded.
You’re going to see lists of requests that I’ve prepared. Feels free to look around!
The request that we’re going to use to create a profile is called “proxyCreateProfile” so let’s get to it!
But before we’re doing anything you’ll notice that. it shows an Invalid address under the contract address field. This is because I put in the environment variable with the name MOCK_PROFILE_CREATOR_PROXY.
We have to set this up before going next!
Let’s hit the environment variables button (The globe icon) on the left side of the UI. Then hit New Button to create a new one.
Now just add new variables to it.
//Here we add
LENS_HUB = 0x60Ae865ee4C725cd04353b5AAb364553f56ceF82
MOCK_PROFILE_CREATOR_PROXY = 0x420f0257D43145bb002E69B14FF2Eb9630Fc4736
//Which is address of both of these contracts on Polygon Mumbai
And then change our Environment variables to the environment we just created.
Now Let’s fill in the parameters.
/**
to = your address
handle = your desired lens handle
imageURI = link to your profile pic
followModule = address to follow module (This is add when you want some fancy logic happen when someone follow you. In this case we just put Null Address to it)
followModuleInitData = data that use to initialized follow module
followNFTURI = uri for followNFT
**/
And here in our case, we'll fill up:
to = <My Address>
handle = <My Desired Handle>
imageURI = https://ipfs.io/ipfs/QmY9dUwYu67puaWBMxRKW98LPbXCznPwHUbhX5NeWnCJbX
followModule = 0x0000000000000000000000000000000000000000
followModuleInitData = 0x00
followNFTURI = https://ipfs.io/ipfs/QmTFLSXdEQ6qsSzaXaCSNtiv6wA56qq87ytXJ182dXDQJS
Now that you filled all of the parameters. Let’s go ahead and click send to create a new Profile!
And then after the transaction is complete. You’re going to have a new Lens Profile of yourself. (You can check the transaction at Polygonscan to verify it too)
Let’s see what it looks like!
I go to tokenOfOwnerByIndex of LensHub contract. go ahead and just out our address (That we just minted a new profile by) and index of 0
It’s going to return us the tokenID of our profile. So that we can use it to query for data again via getProfile request.
Now I just query for the getProfile method. You’ll see the details of my Lens Profile here.
There are also a lot of other methods to call to get data like tokenURI, tokenDataOf But I’ll leave it for you guys to check out!
Tips: We’re going to reuse ProfileID a lot it will be really handy if we store it as a Environment Variable!
Now that we have our own Lens Profile. Let’s get to create a new post!
Just look for the method post inside the Lens Hub folder. This is the method we’re going to use to publish a post.
Now Let’s fill in the parameters
/**
profileId = your profile id from previous
contentURI = URI to the content of the post
collectModule = address to collect module (remember about follow module? this is similar to it. since anyone can collect any post you who post the content can specify how the collect process is going to be like)
collectModuleInitData = data that use to initialized collect module
referenceModule = address to reference module
collectModuleInitData = data that use to initialized reference module
**/
Again here’s what we put:
profileId = 13329
contentURI = https://ipfs.io/ipfs/Qmby8QocUU2sPZL46rZeMctAuF5nrCc7eR1PPkooCztWPz
collectModule = 0x0BE6bD7092ee83D44a6eC1D949626FeE48caB30c
collectModuleInitData = 0x0000000000000000000000000000000000000000000000000000000000000001
referenceModule = 0x0000000000000000000000000000000000000000
collectModuleInitData = 0x00
And after we publish a new post you can read it using method getPub
Here we have to put pubId = 1 because the index in Lens starts with 1 (and not 0!)
And Wallah! We’ve got our post now!
And that’s it! We just create a new Lens Profile and Publish a new post on Lens Protocol! For more information about Lens Protocol please refer to their official documentation at https://docs.lens.xyz/docs