Get Collection

Get Collection by Contract address

Overview

This section details how to retrieve a collection using a contract address through the Assets API.

Properties

addresses

A list of addresses used to query assets.

eg.

[
    "0x2D2438C6281B5115733287fC279f854c868D3ee2",
    "0xFFFFFfFF00000000000000000000000000000417"
]

collectionIds

A list of collection IDs to filter assets on the addresses provided.

eg.

[
    "7672:root:1234",
    "7672:root:2341",
]
import React from 'react'
import { useAccount } from 'wagmi'
import { ChainAddress } from '@fv-asset-registry/common'
import { useAssets } from '@futureverse/asset-register-react'
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 collectionIds = [
      "7672:root:1234",
      "7672:root:2341",
  ]
  
  const {
    assets
  } = useAssets(
    {
      first: 1000,
      addresses: [address as ChainAddress, fpAccount as ChainAddress],
      collectionIds
    },
    { enabled: !!fpAccount && !!address },
  )
  if (!assets) {
    return null
  }

  return (
    <div>
      {assets.map((asset) => <Asset key={asset.id} asset={asset} />)}
    </div>
  )
}


Last updated

Feedback

Docs

© 2023 -> ♾️