useCreateOffer
Hook for creating offers.
Import
import { useCreateOffer } from '@ark-project/react'
Usage
import { useCreateOffer } from '@ark-project/react'
import { useAccount } from '@starknet-react/core'
function App({
tokenAddress,
tokenId,
amount,
brokerId,
currencyAddress,
currencyChainId,
startDate,
endDate,
}) {
const { account } = useAccount()
const { createOffer, data, isLoading, isSuccess } = useCreateOffer()
return (
<>
<button
onClick={async () => {
await createOffer({
account,
tokenAddress,
tokenId,
amount: BigInt(amount),
})
}}
>
Create Offer
</button>
{isLoading && <p>Loading...</p>}
{isSuccess && <div>{data.orderHash}</div>}
</>
)
}
Return Type
import { type useCreateOfferReturnType } from '@ark-project/react'
- Name
createOffer
- Type
- (params: CreateOfferParams) => CreateOfferResult
- Description
Mutation to create an offer. See CreateOfferParams.
- Name
createOfferAsync
- Type
- (params: CreateOfferParams) => Promise<CreateOfferResult>
- Description
Async mutation to create an offer. See CreateOfferParams.
- Name
data
- Type
- CreateOfferResult
- 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
CreateOfferParameters and CreateOfferResponse for more details.