QubicTypeScript

usePossessedAssets

Query all assets currently in the possession of a Qubic identity.

Returns all assets currently in a given identity's possession. Possession represents active control, which can differ from ownership — for example, a smart contract may possess assets on behalf of their owner.

Requires QubicProvider as an ancestor.

Signature

function usePossessedAssets(
  identity: Identity | string | undefined,
  options?: { refetchInterval?: number | false }
): {
  data: Asset[] | undefined
  isLoading: boolean
  error: QubicRpcError | null
}

Usage

import { usePossessedAssets } from "@qubic.org/react"

function PossessedAssets({ identity }: { identity: string }) {
  const { data, isLoading, error } = usePossessedAssets(identity)

  if (isLoading) return <p>Loading...</p>
  if (error) return <p>Error: {error.message}</p>

  return <p>{data?.length ?? 0} asset(s) possessed</p>
}

Parameters

NameTypeDescription
identityIdentity | string | undefinedThe identity to query. Pass undefined to skip the fetch.
options.refetchIntervalnumber | falsePolling interval in milliseconds. Pass false to disable.

Returns

FieldTypeDescription
dataAsset[] | undefinedList of assets possessed by the identity, or undefined while loading.
isLoadingbooleantrue while the first fetch is in progress.
errorQubicRpcError | nullNetwork or parse error.

On this page