React Hooks
useCreateAuction

useCreateAuction

Hook for creating an auction

Usage

import { useCreateAuction } from '@nft/hooks'
import { BigNumber } from 'ethers'
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 (https://docs.ethers.io/v5/api/signer/)
  const [createAuction, { loading }] = useCreateAuction(signer)
 
  const handleClick = async () => {
    await createAuction({
      assetId:
        '56-0x1e4fc916afcf548a2e62c5865fefe2069755a3a3-26744308925107717638226399784052410886289158766077164738526328260523943400243', // Asset of the id to put on auction
      endAt: new Date('2025-12-17T03:24:00'), // Auction end date
      auctionValiditySeconds: 604800, // extra time added to the auction end date to allow seller to accept the auction. After this date, the bids will be expired and the seller will not be able to accept any bid.
      reserveAmount: BigNumber.from(0).toString(), // Minimum price required to accept auction when it ends.
      currencyId: '56-0x19a4866a85c652eb4a2ed44c42e4cb2863a62d51', // Id of the currency to use for the auction
    })
  }
 
  return (
    <button onClick={handleClick} disabled={loading}>
      Create Auction
    </button>
  )
}

Configuration

useCreateAuction(
  signer: Signer | undefined, // Ethers signer: https://docs.ethers.io/v5/api/signer/
)

Return values

;[
  (input: {
    assetId: string
    endAt: Date
    auctionValiditySeconds: number
    reserveAmount: string
    currencyId: string
  }) => Promise<string>, // createAuction. function to create an auction, returns id of the auction
  {
    loading: boolean, // returns true if the auction is being created
  },
]

createAuction

Function to create an auction for an NFT. Returns a promise that resolve with the auction ID created.

Arguments:

{
  assetId: string, // Asset of the id to put on auction
  endAt: Date, // Auction end date
  auctionValiditySeconds: number, // extra time added to the auction end date to allow seller to accept the auction. After this date, the bids will be expired and the seller will not be able to accept any bid.
  reserveAmount: string, // Minimum price required to accept auction (BigNumber converted to string)
  currencyId: string, // Id of the currency to use for the auction
}

loading

Returns true if the auction is being created