Get Collections Owned by a User

Properties

addresses

A list of addresses used to query assets.

e.g.

[
    "0x1213486Ea42bB6EA45bC7434389dA3239738B0E2",
    "0xFffFffff00000000000000000000000000000226"
]

import React from 'react'
import { useAccount } from 'wagmi'
import { ChainAddress } from '@fv-asset-registry/common'
import { useCollections } 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 {
    collections
  } = useCollections(
    {
      first: 1000,
      addresses: [address as ChainAddress, fpAccount as ChainAddress],
    },
    { enabled: !!fpAccount && !!address },
  )
  if (!collections) {
    return null
  }

  return (
    <div>
      {collections.map((collection) => <Collection key={collection.id} collection={collection} />)}
    </div>
  )
}

Last updated

© 2023 -> ♾️