Skip to main content

Auction House

Tools for selling an ERC-721 NFT#

The ZORA Auction House is an open and permissionless system that allows any creator, community, or DAO to buy or sell an NFT. This part of the ZDK provides easy access to the Auction House contract.

Constructor#

Similarly to instantiating the ZORA NFT Module, the Auction House Module requires an ethers.js Signer or Provider, and the chainID of the network you are interacting with.

You can learn more about connecting to ethers.js here

NameTypeDescription
signerOrProviderSigner | ProviderThe Wallet or JSON RPC Provider connected to Ethereum
chainIdnumberThe chainID for the network. 1 for Ethereum Mainnet, or 4 for Rinkeby

import { AuctionHouse } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()const auctionHouse = new AuctionHouse(wallet, 1)

Auction Interface#

Auctions are returned via the ZDK with the following structure:

interface Auction {  approved: boolean  amount: BigNumber  duration: BigNumber  firstBidTime: BigNumber  reservePrice: BigNumber  curatorFeePercentage: number  tokenOwner: string  bidder: string  curator: string  auctionCurrency: string}

Read Functions#


All the functions that are able to get data from the ZORA Auction House smart contract. We recommend using the Zora Indexer if you only need to get Auction House data.

Get an Auction#

NameTypeDescription
auctionIdBigNumberishThe ID for the auction you are trying to fetch
import { AuctionHouse } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()const auctionHouse = new AuctionHouse(wallet, 1)
await auctionHouse.fetchAuction(auctionId)

Get an Auction from a Transaction Receipt#

If you've just created an auction, it may be useful to fetch the auction immediately after it was created. You can do this via the ZDK by simply passing the ethers.js Transaction Receipt from the transaction in which you created the auction.

NameTypeDescription
receiptTransactionReceiptThe receipt from the transaction in which the auction was created
import { AuctionHouse } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
// 1. Connect to the Auction Houseconst auctionHouse = new AuctionHouse(wallet, 1)
// 2. Create an Auctionconst createAuctionTx = await auctionHouse.createAuction(  tokenId,  duration,  reservePrice,  curator,  curatorFeePercentage,  auctionCurrency)
// 3. Await confirmation from the Ethereum Network and receive a receiptconst receipt = await createAuctionTx.wait()
// 4. Finally, get the auction information from the transaction receiptconst auction = await auctionHouse.fetchAuctionFromTransactionReceipt(receipt)

Write Functions#


All the write functions are able to submit transactions to ZORA Auction House smart contract.

Create an Auction#

In order to create an auction, the owner approves their NFT to be used and specifies the auction parameters.

NameTypeDescription
tokenIdBigNumberishThe ID of the token
durationBigNumberishThe length of time to run the auction for, in seconds
reservePriceBigNumberishThe minimum price of the first bid
curatorstringThe address for the auction curator, or the zero address for an uncurated auction
curatorFeePercentagenumberThe % of this auction's highest bid to award the auction curator once the auction has completed
auctionCurrencystringThe address of the ERC-20 contract in which this auction can be run. If set to the zero address, the auction will be run in ETH
tokenAddressstring[optional] The address of the NFT contract the token is coming from. If not specified, the Zora protocol is assumed.
import { AuctionHouse, Zora } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
// 1. Connect to the Auction House and ZORA Protocolconst auctionHouse = new AuctionHouse(wallet, 1)const zora = new Zora(wallet, 1)
// 2. Approve the NFT to be placed on auctionconst approvalTx = await zora.approve(auctionHouse.address, tokenId)
// 3. Await confirmation of the approvalawait approvalTx.wait()
// 3. Create the Auctionconst createAuctionTx = await auctionHouse.createAuction(  tokenId,  duration,  reservePrice,  curator,  curatorFeePercentage,  auctionCurrency)

Approve an auction#

If there is a curator, they can approve any auction in which they have been specified as the curator. Doing so effectively opens up the auction for bidding to take place.

NameTypeDescription
auctionIdBigNumberishThe ID for the auction
approvedbooleanWhether or not the auction is approved
import { AuctionHouse } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const curatorWallet = Wallet.createRandom()const auctionHouse = new AuctionHouse(curatorWallet, 1)
await auctionHouse.setAuctionApproval(auctionId, true)

Create a bid#

If an auction has been approved, any address is able to submit a bid.

NameTypeDescription
auctionIdBigNumberishThe ID of the auction
amountBigNumberishThe amount of the auction's specified currency to be bidding in
import { AuctionHouse } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()const auctionHouse = new AuctionHouse(wallet, 1)
await auctionHouse.createBid(auctionId, amount)

End an Auction#

Once an auction's timer has run out, any address is able to end the auction.

Ending an auction pays out the auction creator and curator, and transfers the NFT to the winner. If the auction was created for a Zora NFT, the auction also respects perpetual equity for the creator and any bid shares that may be present.

NameTypeDescription
auctionIdBigNumberishThe ID of the auction
import { AuctionHouse } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()const auctionHouse = new AuctionHouse(wallet, 1)
await auctionHouse.endAuction(auctionId)

Cancel an Auction#

If an auction has not received any bids yet, either the curator or creator may choose to cancel the auction. Doing so returns the NFT to the original owner and removes the auction from the directory.

NameTypeDescription
auctionIdBigNumberishThe ID for the auction
import { AuctionHouse } from '@zoralabs/zdk'import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()const auctionHouse = new AuctionHouse(wallet, 1)
await auctionHouse.cancelAuction(auctionId)