API and SDK Reference

Hook for making a payment on an active loan

import { useMakePayment } from '@niftyapes/sdk'

Usage

import React from "react";
import { Loan, useMakePayment } from "@niftyapes/sdk";
import { BigNumber } from "ethers";

interface Props {
  loan: Loan;
}

const MakePayment: React.FC<Props> = ({ loan }) => {
  const { write } = useMakePayment({
    paymentAmount: BigNumber.from(loan.loan.minimumPrincipalPerPeriod),
    nftContractAddress: loan.offer.offer.nftContractAddress,
    nftId: BigNumber.from(loan.offer.offer.nftId),
  });

  if (loan.status === "ACTIVE") {
    return <button onClick={() => write?.()}>Make Payment</button>;
  }

  return null;
};

export default MakePayment;

Configuration

The hook requires a minimum payment amount, nft contract address, and a token id.

{
  paymentAmount: BigNumber;
  nftContractAddress: Address;
  nftId: BigNumber;
}

Return Value

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