Integrate Curated Lists
On chain and off chain
Solidity Example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
// Example Solidity contract to integrate with a curated list
import {LSP8Enumerable} from "@lukso/lsp-smart-contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol";
contract IntegrateCuratedList {
function isAddressInCuratedList(address curatedListAddress, address targetAddress) internal view returns (bool) {
// Pad the target address with zeros to create the token ID
bytes32 tokenId = bytes32(uint256(uint160(targetAddress)));
// Instantiate the curated list contract instance
ILSP8IdentifiableDigitalAsset curatedList = ILSP8IdentifiableDigitalAsset(curatedListAddress);
// Check if the token exists
try curatedList.tokenOwnerOf(tokenId) {
return true;
} catch (bytes memory) {
return false;
}
}
function getAllEntries(address curatedListAddress) public view returns (address[] memory) {
// Instantiate the curated list contract instance
LSP8Enumerable curatedList = LSP8Enumerable(curatedListAddress);
// Get total number of entries in the list
uint256 totalEntries = curatedList.totalSupply();
// Initialize an array to hold all addresses
address[] memory entries = new address[](totalEntries);
// Fetch all addresses using tokenAt method
for (uint256 i = 0; i < totalEntries; i++) {
bytes32 tokenId = curatedList.tokenAt(i);
entries[i] = address(uint160(uint256(tokenId)));
}
return entries;
}
}JS/Typescript Example
Last updated