Skip to main content

IDirectListings

thirdweb.com The DirectListings extension smart contract lets you buy and sell NFTs (ERC-721 or ERC-1155) for a fixed price.

Methods

approveBuyerForListing

function approveBuyerForListing(uint256 _listingId, address _buyer, bool _toApprove) external nonpayable

Approve a buyer to buy from a reserved listing.

Parameters

NameTypeDescription
_listingIduint256The ID of the listing to update.
_buyeraddressThe address of the buyer to approve to buy from the listing.
_toApproveboolWhether to approve the buyer to buy from the listing.

approveCurrencyForListing

function approveCurrencyForListing(uint256 _listingId, address _currency, uint256 _pricePerTokenInCurrency) external nonpayable

Approve a currency as a form of payment for the listing.

Parameters

NameTypeDescription
_listingIduint256The ID of the listing to update.
_currencyaddressThe address of the currency to approve as a form of payment for the listing.
_pricePerTokenInCurrencyuint256The price per token for the currency to approve.

buyFromListing

function buyFromListing(uint256 _listingId, address _buyFor, uint256 _quantity, address _currency, uint256 _expectedTotalPrice) external payable

Buy NFTs from a listing.

Parameters

NameTypeDescription
_listingIduint256The ID of the listing to update.
_buyForaddressThe recipient of the NFTs being bought.
_quantityuint256The quantity of NFTs to buy from the listing.
_currencyaddressThe currency to use to pay for NFTs.
_expectedTotalPriceuint256The expected total price to pay for the NFTs being bought.

cancelListing

function cancelListing(uint256 _listingId) external nonpayable

Cancel a listing.

Parameters

NameTypeDescription
_listingIduint256The ID of the listing to cancel.

createListing

function createListing(IDirectListings.ListingParameters _params) external nonpayable returns (uint256 listingId)

Parameters

NameTypeDescription
_paramsIDirectListings.ListingParametersundefined

Returns

NameTypeDescription
listingIduint256undefined

getAllListings

function getAllListings(uint256 _startId, uint256 _endId) external view returns (struct IDirectListings.Listing[] listings)

Returns all listings between the start and end Id (both inclusive) provided.

Parameters

NameTypeDescription
_startIduint256undefined
_endIduint256undefined

Returns

NameTypeDescription
listingsIDirectListings.Listing[]undefined

getAllValidListings

function getAllValidListings(uint256 _startId, uint256 _endId) external view returns (struct IDirectListings.Listing[] listings)

Returns all valid listings between the start and end Id (both inclusive) provided. A valid listing is where the listing creator still owns and has approved Marketplace to transfer the listed NFTs.

Parameters

NameTypeDescription
_startIduint256undefined
_endIduint256undefined

Returns

NameTypeDescription
listingsIDirectListings.Listing[]undefined

getListing

function getListing(uint256 _listingId) external view returns (struct IDirectListings.Listing listing)

Returns a listing at the provided listing ID.

Parameters

NameTypeDescription
_listingIduint256The ID of the listing to fetch.

Returns

NameTypeDescription
listingIDirectListings.Listingundefined

totalListings

function totalListings() external view returns (uint256)

Returns the total number of listings created.

At any point, the return value is the ID of the next listing created.

Returns

NameTypeDescription
_0uint256undefined

updateListing

function updateListing(uint256 _listingId, IDirectListings.ListingParameters _params) external nonpayable

Parameters

NameTypeDescription
_listingIduint256undefined
_paramsIDirectListings.ListingParametersundefined

Events

BuyerApprovedForListing

event BuyerApprovedForListing(uint256 indexed listingId, address indexed buyer, bool approved)

Emitted when a buyer is approved to buy from a reserved listing.

Parameters

NameTypeDescription
listingId indexeduint256undefined
buyer indexedaddressundefined
approvedboolundefined

CancelledListing

event CancelledListing(address indexed listingCreator, uint256 indexed listingId)

Emitted when a listing is cancelled.

Parameters

NameTypeDescription
listingCreator indexedaddressundefined
listingId indexeduint256undefined

CurrencyApprovedForListing

event CurrencyApprovedForListing(uint256 indexed listingId, address indexed currency, uint256 pricePerToken)

Emitted when a currency is approved as a form of payment for the listing.

Parameters

NameTypeDescription
listingId indexeduint256undefined
currency indexedaddressundefined
pricePerTokenuint256undefined

NewListing

event NewListing(address indexed listingCreator, uint256 indexed listingId, address indexed assetContract, IDirectListings.Listing listing)

Emitted when a new listing is created.

Parameters

NameTypeDescription
listingCreator indexedaddressundefined
listingId indexeduint256undefined
assetContract indexedaddressundefined
listingIDirectListings.Listingundefined

NewSale

event NewSale(address indexed listingCreator, uint256 indexed listingId, address indexed assetContract, uint256 tokenId, address buyer, uint256 quantityBought, uint256 totalPricePaid)

Emitted when NFTs are bought from a listing.

Parameters

NameTypeDescription
listingCreator indexedaddressundefined
listingId indexeduint256undefined
assetContract indexedaddressundefined
tokenIduint256undefined
buyeraddressundefined
quantityBoughtuint256undefined
totalPricePaiduint256undefined

UpdatedListing

event UpdatedListing(address indexed listingCreator, uint256 indexed listingId, address indexed assetContract, IDirectListings.Listing listing)

Emitted when a listing is updated.

Parameters

NameTypeDescription
listingCreator indexedaddressundefined
listingId indexeduint256undefined
assetContract indexedaddressundefined
listingIDirectListings.Listingundefined