Auction House
#
Tools for selling an ERC-721 NFTThe 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.
#
ConstructorSimilarly 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
Name | Type | Description |
---|---|---|
signerOrProvider | Signer | Provider | The Wallet or JSON RPC Provider connected to Ethereum |
chainId | number | The 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 InterfaceAuctions 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 FunctionsAll 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 AuctionName | Type | Description |
---|---|---|
auctionId | BigNumberish | The 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 ReceiptIf 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.
Name | Type | Description |
---|---|---|
receipt | TransactionReceipt | The 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 FunctionsAll the write functions are able to submit transactions to ZORA Auction House smart contract.
#
Create an AuctionIn order to create an auction, the owner approves their NFT to be used and specifies the auction parameters.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID of the token |
duration | BigNumberish | The length of time to run the auction for, in seconds |
reservePrice | BigNumberish | The minimum price of the first bid |
curator | string | The address for the auction curator, or the zero address for an uncurated auction |
curatorFeePercentage | number | The % of this auction's highest bid to award the auction curator once the auction has completed |
auctionCurrency | string | The 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 |
tokenAddress | string | [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 auctionIf 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.
Name | Type | Description |
---|---|---|
auctionId | BigNumberish | The ID for the auction |
approved | boolean | Whether 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 bidIf an auction has been approved, any address is able to submit a bid.
Name | Type | Description |
---|---|---|
auctionId | BigNumberish | The ID of the auction |
amount | BigNumberish | The 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 AuctionOnce 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.
Name | Type | Description |
---|---|---|
auctionId | BigNumberish | The 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 AuctionIf 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.
Name | Type | Description |
---|---|---|
auctionId | BigNumberish | The 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)