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.

Thanks,

3 Likes

Hi @maxareo,

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.

2 Likes

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

I'd love to assist in creating such a pull request. I personally can very much relate to the need and believe this will be a very good addition to the OZ library. As for existing examples, I suppose we can refer to cryptopunk as a start? Please let me know if there are more things to consider besides your already informative design ideas :wink:

1 Like

NFT marketplace functionality is not in the roadmap for the foreseeable future.

I'd like to share some thoughts if anyone is still interested in making it into an interesting project. Hit me up on discord: Brief_Kandle#6146. or tell me you think my whole notion is wrong.

First, the idea of making a bid-and-ask extension is conceptually appealing. To me, the bid-and-ask is the very basis of nft trading. On top of it, other trading-strategies contracts can be built. For example, if you want to sweep the price floor, you can build a contract that sifts through the ask_mapping and then purchases the lowest ask. If your contract is so good, everyone can start to use it. Besides, it seems like building it inside the nft contract could save user gas because you don't need to getApproval for a third-party contract. I need to do some testing on the gas part, though.

Second, old nft projects that did not have the chance to use this extension still can benefit from the standard. As soon as we have a standardized bid-and-ask extension, we could make a (uniswap-like) factory that can create a unique "marketplace" contract (with bid and ask mechanisms) for each erc721 contract. Anyone may call this "factory" contract to generate a "marketplace" contract for any NFT. It's like creating the AMM ERC20 trading pair. FREE OF CHARGE. NO ROYALTIES. Anyone can trade.

Third, the traffic issue. Admittedly, opensea dominates the traffic and market volume. We can never compete against it. What I am envisioning is an indexing front-end that routes through all erc721 contracts (if the marketplace is built within) and its own marketplace contract (if it is an old nft contract). In the end, it could be a cool, decentralized protocol.

Let me know what you guys and the community think. Peace~

1 Like

@stephanie_zhang I have actually had the implementations written. Happy to share and talk about the applicability.

1 Like

Great to hear!! Did you DM me on discord? Let's discuss.