Fetching Trees

getTree

Get a Tree by its ID.

const tree = await hatsSubgraphClient.getTree({
    chainId,
    treeId,
    props,
});

Arguments:

{
    chainId: number;
    treeId: number;
    props: TreePropsConfig;
}
  • chainId - ID of the chain to fetch from.

  • treeId - ID of the Tree to fetch (Tree's top-hat domain - first 4 bytes of the top-hat ID).

  • props - Tree's properties to fetch, including the ones of nested objects. Check the TreePropsConfig type for the available properties and query filters.

Response:

Tree

A Tree object, containing the chosen properties.

Example:

getTreesByIds

Get Trees by their IDs.

Arguments:

  • chainId - ID of the chain to fetch from.

  • treeIds - IDs of the Trees to fetch (Tree's top-hat domain - first 4 bytes of the top-hat ID).

  • props - Tree's properties to fetch, including the ones of nested objects. Check the TreePropsConfig type for the available properties and query filters.

Response:

An array of Tree objects, containing the chosen properties.

Example:

getTreesPaginated

Paginate over Trees.

Arguments:

  • chainId - ID of the chain to fetch from.

  • props - Tree's properties to fetch, including the ones of nested objects. Check the TreePropsConfig type for the available properties and query filters.

  • page - Number of page to fetch.

  • perPage - Number of Trees to fetch in each page.

Response:

An array of Tree objects, containing the chosen properties.

Example:

Last updated