NFT bid/ask mechanism

Hey guys,

I like the ERC721 contracts on OZ, and the new Contracts Wizard is definitely an awesome tool.

I am just wondering if you could also develop an ERC721 extension with bidding, asking functionalities as implemented by crypto punks. That is, any one can make a bid to a NFT, and the owner can also set up an ask price. This way, NFTs would no longer need an exchange to be traded. They can be traded anywhere, even on Twitter, Facebook, etc.



Hi @maxaero,

My thoughts on this is there isn’t a need, whilst projects can use marketplaces such as OpenSea. The reason for this is the marketplaces have a much larger audience than any one collectible may have.

Legacy NFTs included their own marketplaces (such as CryptoPunks) but I believe that when they were later made available on marketplaces that supported ERC721 (by wrapping them as an ERC721), then there was a larger audience and market, making trading and collecting a lot easier.

Interested to hear more thoughts from the community.

Thanks for the reply and I’d like to hear more from the community as well. As far as I know, NFTs are not merely for art works. It can be virtual items, ownership, or even the right to build a house on a decentraland. Clearly, existing marketplaces are not for this type of NFTs. A built-in bid/ask mechanism could add liquidity to this abstract type of NFTs before a marketplace for it gets popular. IMHO.

1 Like

What would the bid/ask functionality look like, in terms of interface and behavior?

I think it could make sense to have this extension, if there is a standard way that the bid/ask mechanics would work. I wouldn’t want to go into the weeds of different kinds of auctions etc.

1 Like

It would require a struct recording bid/ask information:

struct NFTInfo {
    uint256 _tokenId;
    uint256 _offerPrice;
    uint256 _maxBidPrice;
    bool _isForSale;
    address _bidder;

and a mapping from tokenId to this struct:

mapping(uint256 => NFTInfo) _NFTDetails;

And the interfaces for ERC20 tokens would be like:

function bid(uint256 tokenId, uint256 price) external returns(bool);
function ask(uint256 tokenId, uint256 price) external returns(bool);

For Ethers:

function bid(uint256 tokenId) external payable returns(bool);
function ask(uint256 tokenId) external returns(bool);

Internally, it would require maintaining an accounting system.

In terms of behaviors, a bid action is to send tokens to an owner when an owner does not have a specific ask price set up yet. The bid information is recorded regardless and no transfer would happen. Both the market and the owner would know a bidder is willing to and has paid X amount of tokens to purchase this NFT. If the owner has set up an offer price, depending upon if the bid is higher or lower than the offer price, a transaction may or may not be triggered. An ask function, on the other hand, is for the owner to set up an offering price of a NFT he actually owns. There may or may not be a bidder yet. If there is a bidder and if the offer price is higher than the current bid price, nothing will happen; if the offer price is lower than or equal to the bid price, a transaction is triggered. If there is no bidder, nothing will happen too. The market would know the owner is willing to offer X amount of tokens to sell a NFT. Since the liquidity is low, a struct maintaining one ask price and one bid price suffices.

1 Like

The ask part makes sense to me and it would basically mean to put a price on an NFT so that anyone that provides enough payment can take ownership of it.

Bidding ETH seems more complicated because the bidder would need to make an ETH deposit on the contract so that the owner can then execute the trade, but the bidder would also need a way to retrieve that ETH if they want to take the offer back.

Bidding ERC20 tokens seems a little more simple as I imagine it could work with approve to the NFT contract, and when the owner executes the trade it would trigger transferFrom. However, this makes it more complicated to get a list of legitimate bids on the client side, since it’s not a given that a bidder will have enough balance to execute the trade.

It’s really only necessary to support tokens since people can use WETH, although the wrapping makes for worse UX.

If we were to add something like this to OpenZeppelin Contracts I would want to see some existing NFT contracts with bid/ask mechanism to make sure we don’t miss anything.

1 Like