API and SDK Reference

Hook for purchasing an NFT with financing.

import { useBuyWithFinancing } from '@niftyapes/sdk'

Usage

import React from "react";
import { useBuyWithFinancing, Offer } from "@niftyapes/sdk";
import { useWaitForTransaction } from "wagmi";

interface Props {
  offer: Offer;
}

const ExecuteOffer: React.FC<Props> = ({ offer }) => {
  // Executes a loan
  const { data, write } = useBuyWithFinancing({ offer })

  // Wait for the transaction with wagmi's `useWaitForTransaction`
  const {
    isLoading,
    isSuccess,
    isError,
  } = useWaitForTransaction({ hash: data?.hash })

  if (offer.status === "ACTIVE") {
    return <button onClick={() => write?.()}>Buy with Financing</button>
  }

  return null;
}

export default ExecuteOffer;

Configuration

The hook requires a valid Offer and a signature

{ offer: Offer }

Return Value

{
  data?: TransactionResponse
  error?: Error
  isError: boolean
  isIdle: boolean
  isLoading: boolean
  isSuccess: boolean
  write: (() => void) | undefined
  status: 'idle' | 'error' | 'loading' | 'success'
}