使用莱卡交互Lens
轻松地使用莱卡探寻 Lens Protocol
最后更新于
轻松地使用莱卡探寻 Lens Protocol
最后更新于
你们中的许多人可能听说过 Lens Protocol, 这是AAVE团队构建的新 Web3 社交图协议。 解决我们目前在基于Web2生活中使用的社交媒体中的许多重大问题。
更多关于 Lens Protocol 的详情可以在它的文档中找到 https://docs.lens.xyz/docs/what-is-lens
Introduction
Lens Protocol 是 Polygon 链上的 Web3 社交图谱。 它旨在使创作者能够拥有自己与社区之间的链接,形成一个完全组合的,用户拥有的社交图。 该协议是从地面上构建的,考虑到模块化,允许添加新功能和修复程序,同时确保不可变的用户拥有的内容和社交关系。
本文旨在成为一个小帮手,我们将在其中探索如何使用莱卡与 Lens Protocol 交互!
我们接下来要一起做的:
我么将探索 在 Polygon Mumbai 测试网上的 Lens Protocol。
通过 MockProfileCreationProxy 合约来创建我们的 Lens Handle。
通过 LensHub Proxy 来创建一个新的推文
Lens Protocol 的团队将其设计成模块化的。这样就使得很容易扩展 Lens 的社区,Lens 将很多功能都变成 ERC721 兼容的形式。因此如果有人想给 Lens Protocol 加入更多的 modeul。他们只需要写一个新的模块然后插入即可。就是这么简单。
你将要交互的合约叫做 "Lens Hub"。这个合约与是 Lens Protocol 大多数交互的入口。
在下面链接中,你可以看到在不同的链上的部署的合约列表: https://docs.lens.xyz/docs/deployed-contract-addresses
在开始做任何事情之前,请确认你的钱包在 Mumbai 测试网上有一些 MATIC,你可以在 https://faucet.polygon.technology/ 获取一些 MATIC。
在 Polygon Mumbai 测试网上创建 Lens Profile 需要使用一些跟其他交互不同的方式来交互。
Lens Protocol 有一个白名单,这个白名单限制了谁可以创建 Lens Profile。通常情况下,我们的地址不在白名单里面。但是我们可以通过 "MockProfileCreationProxy" 来创建 Lens Profile,
MockProfileCreationProxy 在 Polygon Mumbai 的地址是0x420f0257D43145bb002E69B14FF2Eb9630Fc4736
让我们继续吧。
为了让你们更方便的跟上这个教程,我把在这篇文章中使用的 collection 导出了,你可以在从下面的代码块中复制。
{"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}
然后在 web.getlaika.app 上点击 "Import Collection",然后将刚刚下载的 JSON 导入进去。
你将会看到我们已经准备好的请求列表:
我们用来创建一个 profile 的请求叫做 "proxyCreateProfile",让我们开始吧。
在我们做任何事情之前,你会注意到,在 contract address 那一栏会显示 Invalid Address,这是因为我们放入了名为 MOCK_PROFILE_CREATOR_PROXY 的环境变量。
在开始与合约交互之前,我们需要设置这一环境变量。
我们点击 UI 左侧的 environment 按钮,然后点击 New 按钮新建一个。
现在我们把新的环境变量加进去。
//Here we add
LENS_HUB = 0x60Ae865ee4C725cd04353b5AAb364553f56ceF82
MOCK_PROFILE_CREATOR_PROXY = 0x420f0257D43145bb002E69B14FF2Eb9630Fc4736
//Which is address of both of these contracts on Polygon Mumbai
切换到我们刚刚创建的新环境中。
现在我们可以填入参数了。
/**
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
**/
在这里的场景里,我们会填入:
to = <My Address>
handle = <My Desired Handle>
imageURI = https://ipfs.io/ipfs/QmY9dUwYu67puaWBMxRKW98LPbXCznPwHUbhX5NeWnCJbX
followModule = 0x0000000000000000000000000000000000000000
followModuleInitData = 0x00
followNFTURI = https://ipfs.io/ipfs/QmTFLSXdEQ6qsSzaXaCSNtiv6wA56qq87ytXJ182dXDQJS
现在你已经填入了所有的参数,让我们点击 Send 来创建一个新的 Profile 吧。
在交易完成后,你就有一个属于你自己的 Lens Profile 了(你可以在 polygonscan 上确认此交易并 verify).
让我们看看它是什么样子!
我们找到 Lenshub 合约里面的 tokenOfOwnerByIndex 方法,然后填入我们的地址(刚刚获得新 Profile的地址)和 index 0。
它会返回我们个人 Profile 的 tokenID。这样我们就可以通过 getProfile 请求再次使用它来查询数据。
我现在查询一下 getProfile 方法。你就会看到自己的 Lens Profile 详情。
还有很多其他方法可以获取数据,例如 tokenURI, tokenDataOf,但这里先不赘述了。
小贴士:我们将多次重用ProfileID,如果我们将它存储为环境变量,这将非常方便!
我们有了 Lens Profile 后,就可以创建新的 Post。
只需在Lens Hub文件夹中找到 post 方法。这是我们将要用来发布一个 post 的方法。
现在我们需要填入参数:
/**
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
**/
具体的,我们填入:
profileId = 13329
contentURI = https://ipfs.io/ipfs/Qmby8QocUU2sPZL46rZeMctAuF5nrCc7eR1PPkooCztWPz
collectModule = 0x0BE6bD7092ee83D44a6eC1D949626FeE48caB30c
collectModuleInitData = 0x0000000000000000000000000000000000000000000000000000000000000001
referenceModule = 0x0000000000000000000000000000000000000000
collectModuleInitData = 0x00
创建完成后,你可以通过 getPubB 方法读取到。
这里我们必须设置 pubId = 1,因为Lens中的索引从1开始(而不是0!)
笑死,我们现在已经能拿到我们发的 post 了。
就是这样!我们只是创建了一个新的 Lens Profile,并发布了一个关于 Lens Profile 的新 Post!有关 Lens Protocol 的更多信息,请参阅其官方文档 https://docs.lens.xyz/docs