Claiming Hats

Hats can be made claimable by using the Multi Claims Hatter module.

The following functions support the claiming functionality enabled by this module.

accountCanClaim

Check whether an account can claim a given hat.

const canClaim = await hatsClient.accountCanClaim({
    hatId,
    account,
});

Arguments:

{
    hatId: bigint;
    account: Address;
}
  • hatId - The hat ID to claim.

  • account - The claiming account's address.

Response:

boolean

true if can claim, false otherwise.

canClaimForAccount

Check whether a hat can be claimed on behalf of a given account.

const canClaimFor = await hatsClient.canClaimForAccount({
    hatId,
    account,
});

Arguments:

{
    hatId: bigint;
    account: Address;
}
  • hatId - The hat ID to claim-for.

  • account - The account address to claim on behalf of.

Response:

boolean

true if can claim-for, false otherwise.

claimHat

Claim a hat for the calling account.

const claimHatResult = await hatsClient.claimHat({
    account,
    hatId,
});

Arguments:

{
    account: Account | Address;
    hatId: bigint;
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • hatId - ID of the hat to claim.

Response:

{
  status: "success" | "reverted";
  transactionHash: `0x${string}`;
}
  • status - "success" if transaction was successful, "reverted" if transaction reverted.

  • transactionHash - transaction's hash.

claimHatFor

Claim a hat on behalf of a chosen account.

const claimHatForResult = await hatsClient.claimHatFor({
    account,
    hatId,
    wearer,
});

Arguments:

{
    account: Account | Address;
    hatId: bigint;
    wearer: Address;
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • hatId - ID of the hat to claim-for.

  • wearer - Address for which to claim the hat for.

Response:

{
  status: "success" | "reverted";
  transactionHash: `0x${string}`;
}
  • status - "success" if transaction was successful, "reverted" if transaction reverted.

  • transactionHash - transaction's hash.

multiClaimHatFor

Claim a hat on behalf of multiple accounts.

const claimHatForResult = await hatsClient.multiClaimHatFor({
    account,
    hatId,
    wearers,
});

Arguments:

{
    account: Account | Address;
    hatId: bigint;
    wearers: Address[];
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • hatId - ID of the hat to claim-for.

  • wearers - Addresses for which to claim the hat for.

Response:

{
  status: "success" | "reverted";
  transactionHash: `0x${string}`;
}
  • status - "success" if transaction was successful, "reverted" if transaction reverted.

  • transactionHash - transaction's hash.

Last updated