Fetching Hats
getHat
const hat = await hatsSubgraphClient.getHat({
chainId,
hatId,
props,
});{
chainId: number;
hatId: bigint;
props: HatPropsConfig;
}HatgetHatsByIds
Last updated
const hat = await hatsSubgraphClient.getHat({
chainId,
hatId,
props,
});{
chainId: number;
hatId: bigint;
props: HatPropsConfig;
}HatLast updated
const res = await client.getHat({
chainId: 10, // optimism
hatId: BigInt(
"0x0000000100020001000100000000000000000000000000000000000000000000"
),
props: {
maxSupply: true, // get the maximum amount of wearers for the hat
wearers: { // get the hat's wearers
props: {}, // for each wearer, include only its ID (address)
},
events: { // get the hat's events
props: {
transactionID: true, // for each event, include the transaction ID
},
filters: {
first: 10, // fetch only the latest 10 events
},
},
},
});const hats = await hatsSubgraphClient.getHatsByIds({
chainId,
hatIds,
props,
});{
chainId: number;
hatIds: bigint[];
props: HatPropsConfig;
}Hat[]const res = await client.getHatsByIds({
chainId: 10, // optimism
hatIds: [
BigInt("0x0000000100020001000100000000000000000000000000000000000000000000"),
BigInt("0x0000000100020001000000000000000000000000000000000000000000000000"),
],
props: {
wearers: { // get each hat's wearers
props: {
currentHats: { // for each wearer, get its hats
props: {}, // for each hat, include only its ID
},
},
},
},
});