useFulfillOffer

Hook for fulfilling offers.

Import

import { useFulfillOffer } from '@ark-project/react'

Usage

import { useFulfillOffer } from '@ark-project/react'
import { useAccount } from '@starknet-react/core'

const FulfillOfferComponent = ({
  orderHash,
  tokenAddress,
  tokenId,
  brokerId,
}) => {
  const { account } = useAccount()
  const { fulfillOffer, data, isLoading, isSuccess } = useFulfillOffer()

  return (
    <>
      <button
        onClick={async () => {
          await fulfillOffer({
            account,
            orderHash,
            tokenAddress,
            tokenId,
            brokerId,
          })
        }}
      >
        Fulfill Offer
      </button>
      {isLoading && <p>Loading...</p>}
      {isSuccess && <div>{data.transactionHash}</div>}
    </>
  )
}

Return Type

import { type useFulfillOfferReturnType } from '@ark-project/react'
  • Name
    fulfillOffer
    Type
    (params: FulfillOfferParams) => FulfillOfferResult
    Description

    Mutation to fulfill an offer. See FulfillOfferParams.

  • Name
    fulfillOfferAsync
    Type
    (params: FulfillOfferParams) => Promise<FulfillOfferResult>
    Description

    Async mutation to fulfill an offer. See FulfillOfferParams.

  • Name
    data
    Type
    FulfillOfferResult
    Description

    The data returned from the mutation.

Parameters

  • Name
    config (optional)
    Type
    Config | undefined
    Description

    Config to use instead of retrieving from the nearest ArkProvider.

Actions

FulfillOfferParameters and FulfillOfferResponse for more details.