React Hooks


Hook to create and accept an invitation. This helps to create a referral system. A primary user can create an invitation ID while a secondary user can use that ID to accept the invitation.


import { useInvitation } from '@nft/hooks'
import React from 'react'
export default function Component() {
  const signer = undefined // type of "Signer & TypedDataSigner" Get the signer from the wallet. Need to be an Ethers Signer (
  const { create, accept, accepting, creating } = useInvitation(signer)
  const handleGetInvitation = async () => {
    const id = await create()
    alert(`Your invitation ID: ${id}`)
  const handleAcceptInvitation = async () => {
    await accept('0a631dfb-b3f4-443e-8fb5-ddfd3e7f53f4')
    alert(`Invitation accepted`)
  return (
      {/* A primary user can create the invitation ID */}
      <button onClick={handleGetInvitation} disabled={creating}>
        Create invitation ID
      {/* A secondary user can accept the invitation */}
      <button onClick={handleAcceptInvitation} disabled={accepting}>
        Accept Invitation


  signer: Signer | undefined, // Ethers signer:

Return values

  create: () => Promise<string>, // Function to create an invitationId. It returns the ID.
  accept: (invitationId: string) => Promise<string>, // Function to accept an invitation. Takes the invitation id as parameter and returns that ID.
  accepting: boolean, // Returns "true" while accepting the invitation.
  creating: boolean  // Returns "true" while creating the invitation ID.


Function to create an invitation ID. It returns the ID.


Function to accept an invitation. It returns the ID. The creator of the ID cannot accept an invitation using and ID he created.


invitationId: string


Returns true while accepting the invitation.


Returns true while creating the invitation ID.