This section provides you with the tools to efficiently manage and retrieve collectibles data. Here's a brief overview of what you'll find:
Basic Filtering: Filter collectibles based on ownership and collection criteria, allowing you to retrieve items owned by specific users or belonging to particular collections.
Comparative Filtering: Advanced filtering techniques, including direct equal comparisons, property existence filter queries, and text searches, to narrow down your results more precisely.
Pagination: Handle large datasets effectively by implementing pagination, ensuring a smooth and responsive user experience even when dealing with extensive amounts of collectibles data.
Basic Filtering
Filter Collectibles owned by a user and collection
A list of collection IDs to filter assets on the addresses provided.
e.g.
[
"7672:root:1234",
"7672:root:2341",
]
Since both the above properties are optional you can use the independently or together based on the use case. For example filtering using addresses and collectionIds will return all the collectibles in the specified collections owned by the addresses.
import React from 'react'
import { useAccount } from 'wagmi'
import { ChainAddress } from '@futureverse/asset-register/types'
import { useAssets } from '@futureverse/asset-register-react/v2'
import { useFuturePassAccountAddress } from '@futureverse/react'
// React component to render all collectibles owned by a FuturePass user logged in.
export const AssetList = () => {
// Get EOA address
const { address } = useAccount()
// Get FV address
const { data: fpAccount } = useFuturePassAccountAddress()
const {
assets
} = useAssets(
{
first: 1000,
addresses: [address as ChainAddress, fpAccount as ChainAddress],
},
{ enabled: !!fpAccount && !!address },
)
if (!assets) {
return null
}
return (
<div>
{assets.map((asset) => <Asset key={asset.id} asset={asset} />)}
</div>
)
}
import { AssetRegister } from '@futureverse/asset-register'
import { AssetsModel } from '@futureverse/asset-register/models';
const ar = new AssetRegister({
...
})
const assets = await ar.assets({
addresses: [
"0x2D2438C6281B5115733287fC279f854c868D3ee2",
"0xFFFFFfFF00000000000000000000000000000417"
],
collectionIds: [
"7672:root:1234",
"7672:root:2341",
]
}).execute()[0] as AssetsModel
query GetAssets($addresses: [ChainAddress!]!, $collectionIds: [CollectionId!], $after: String, $first: Float) {
assets(
addresses: $addresses
collectionIds: $collectionIds
after: $after
first: $first
) {
pageInfo {
endCursor
hasNextPage
}
edges {
node {
id
collectionId
tokenId
assetType
assetTree {
data
nodeId
}
schema {
name
namespace
schema
version
}
ownership {
__typename
... on SFTAssetOwnership {
id
balancesOf(addresses: $addresses) {
balance
owner {
address
}
}
}
... on NFTAssetOwnership {
owner {
address
}
}
}
metadata {
attributes
properties
uri
}
links {
__typename
... on SFTAssetLink {
parentLinks(addresses: $addresses) {
collectionId
tokenId
}
}
... on NFTAssetLink {
parentLink {
collectionId
tokenId
}
}
}
collection {
id
chainId
chainType
location
name
}
}
}
}
}
In addition to address and collection-based filtering, further filtering can be done using a direct equal comparison of values, values that fit in a specified range or even a direct text search.
Filter Types
Equal
The name property is used to target the correct item to filter. The equal filter must take a string property as the value, even if the targeted property is a number.