To refer to the contents of a curated list in your smart contract you can simply rely on all the methods available under LSP8IdentifiableDigitialAsset and its Enumerable extension, with the target address being the curated lists' address on the blockchain.
Entry ids in a curated list are stored as bytes32 so in order to check if a particular blockchain address is an entry within a curated you'd first pad the address with 0s and then rely on the getOperatorsOf(tokenId)method.
If you want to read all the addresses of the entries in a list, you can fetch the totalSupply() and then using that result and the tokenAt(uint256 index)method, fetch the address for the full set.
// SPDX-License-Identifier: MITpragmasolidity ^0.8.24;// Example Solidity contract to integrate with a curated listimport {LSP8Enumerable} from"@lukso/lsp-smart-contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol";contract IntegrateCuratedList {functionisAddressInCuratedList(address curatedListAddress,address targetAddress) publicviewreturns (bool) {// Pad the target address with zeros to create the token IDbytes32 tokenId =bytes32(uint256(uint160(targetAddress)));// Instantiate the curated list contract instance LSP8Enumerable curatedList =LSP8Enumerable(curatedListAddress);// Check if the target address is an operator of the token IDaddress[] memory operators = curatedList.getOperatorsOf(tokenId);return operators.length >0; }functiongetAllEntries(address curatedListAddress) publicviewreturns (address[] memory) {// Instantiate the curated list contract instance LSP8Enumerable curatedList =LSP8Enumerable(curatedListAddress);// Get total number of entries in the listuint256 totalEntries = curatedList.totalSupply();// Initialize an array to hold all addressesaddress[] memory entries =newaddress[](totalEntries);// Fetch all addresses using tokenAt methodfor (uint256 i =0; i < totalEntries; i++) {bytes32 tokenId = curatedList.tokenAt(i); entries[i] =address(uint160(uint256(tokenId))); }return entries; }}
JS/Typescript Example
// Example TypeScript calls to interact with curated listsimport { ethers } from"ethers";import LSP8Enumerable from'@lukso/lsp8-contracts/artifacts/LSP8Enumerable.json';// Instantiate provider and signerconstprovider=newethers.providers.JsonRpcProvider("<RPC_URL>");constsigner=provider.getSigner();// Function to check if an address is in a curated listasyncfunctionisAddressInCuratedList(curatedListAddress:string, targetAddress:string):Promise<boolean> {constcuratedListContract=newethers.Contract(curatedListAddress, LSP8EnumerableABI, provider);consttokenId=ethers.utils.hexZeroPad(targetAddress,32);constoperators=awaitcuratedListContract.getOperatorsOf(tokenId);returnoperators.length>0;}// Function to get all entries from a curated listasyncfunctiongetAllEntries(curatedListAddress:string):Promise<string[]> {constcuratedListContract=newethers.Contract(curatedListAddress, LSP8EnumerableABI, provider);consttotalSupply=awaitcuratedListContract.totalSupply();constentries:string[] = [];for (let i =0; i < totalSupply; i++) {consttokenId=awaitcuratedListContract.tokenAt(i);constentryAddress=ethers.utils.getAddress(tokenId.slice(0,42));entries.push(entryAddress); }return entries;}