Help in understanding the buy and sell functions in this NFT contract

I have a fairly basic question here about the contract below and hoping someone can help. Obviously NFT marketplaces can be designed and coded many different ways, but in this particular case with the contract below I am not really understanding the practicality of the contract. Main question is...

1.)The sell function is called by the seller so does that mean that he can simply sell all his/her NFT's to the marketplace even though there is no buyer? It appears to me the NFT marketplace will buy the NFTs in the sell function but they do not necessarily transfer immediately to a buyer? Its safe to say there may not even be a buyer? So in this contract am i correct that the seller can just sell them to the marketplace and then the marketplace will own them and wait for a buyer to come along later?

This is obviously in contrast to the more common type of marketplaces that facilitate a transaction btwn the buyer and seller. Meaning a buyer comes along and wants to buy an NFT, so a createMarketSale function or something like this sends the NFT to the buyer and the funds to the seller all in a single transaction right? That is not happening in this scenario. Its what was described in my first paragraph right? Seller can simply sell to marketplace even though there is no buyer yet. Anyone?

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "./TrustfulOracle.sol";
import "../DamnValuableNFT.sol";

contract Exchange is ReentrancyGuard {
    using Address for address payable;

    DamnValuableNFT public immutable token;
    TrustfulOracle public immutable oracle;

    event TokenBought(address indexed buyer, uint256 tokenId, uint256 price);
    event TokenSold(address indexed seller, uint256 tokenId, uint256 price);

    constructor(address oracleAddress) payable {
        token = new DamnValuableNFT();
        oracle = TrustfulOracle(oracleAddress);

    function buyOne() external payable nonReentrant returns (uint256) {
        uint256 amountPaidInWei = msg.value;
        require(amountPaidInWei > 0, "Amount paid must be greater than zero");

        // Price should be in [wei / NFT]
        uint256 currentPriceInWei = oracle.getMedianPrice(token.symbol());

        require(amountPaidInWei >= currentPriceInWei, "Amount paid is not enough");

        uint256 tokenId = token.safeMint(msg.sender);

        payable(msg.sender).sendValue(amountPaidInWei - currentPriceInWei);

        emit TokenBought(msg.sender, tokenId, currentPriceInWei);

        return tokenId;

    function sellOne(uint256 tokenId) external nonReentrant {
        require(msg.sender == token.ownerOf(tokenId), "Seller must be the owner" );
        require(token.getApproved(tokenId) == address(this), "Seller must have approved transfer" );

        // Price should be in [wei / NFT]
        uint256 currentPriceInWei = oracle.getMedianPrice(token.symbol());
        require( address(this).balance >= currentPriceInWei, "Not enough ETH in balance");

        token.transferFrom(msg.sender, address(this), tokenId);


        emit TokenSold(msg.sender, tokenId, currentPriceInWei);

    receive() external payable {}

If the seller wants to sell the NFT even though there is no buyer, the NFT will not be transferred to the marketplace contract. the seller approves the NFT marketplace contract to send this NFT to any user at any time.

in that case, if one buyer wants to buy this NFT, he will transfer money to the seller and the marketplace will transfer this NFT from the seller to the buyer.

Thanks for the response. So who calls the sell function than? And when is it triggered? Is that all set up on the front end along with the "approval" giving the markeplace the authority to transfer the NFT from the seller to the buyer? Meaning, a buyer calls comes along and triggers the buy function and then that triggers both the approve and sell functions? That all is happening on the front end right? The sell function must be triggered automatically and directly following the "buy" but it is all synced up on the front end right? Because buy and sell on the back-end (in the smart contracts) are separate functions entirely and buy does not trigger sell. Buy does not send the NFT to the buyer and the $ to the seller, it only does the former (sends the NFT).

If you want to hire dev, please ping me on telegram.
I think you are a bit confused about NFT marketplace. I have practical experience with developing NFT marketplace.

No offense but the code does not work as you described. The code below does however. This transfers the NFT to buyer and the funds (ETH) to the seller. The original code I showed you is not doing that. The buy and sell are entirely separate functions and it involves minting/burning, so i am asking how it all syncs together? Meaning how does a "buy" transfer funds to the seller? (its not in the smart contract under the buy function) My guess is it is happening on the front end (like the approval- this is implemented on the front end), or maybe its something else but maybe someone else can explain who sees this.

Cool if you can't explain but thanks for trying. Im certain i don't need to hire you though lol. I don't think providing incorrect feedback and dropping a sales pitch is gonna work for most people here or at least they won't like it so just a tip may wanna keep that off the forums. Unless of course you can explain things correctly and explain them well.

  function createMarketSale(address nftContract, uint256 itemId) public payable nonReentrant {
    uint256 price = idToMarketToken[itemId].price;
    uint256 tokenId = idToMarketToken[itemId].tokenId;
    require(msg.value == price, "Please submit the asking price in order to continue");
    //transfer the amount to the seller
    //transfer token/NFT from contract address to the buyer
    IERC721(nftContract).transferFrom(address(this), msg.sender, tokenId);
    idToMarketToken[itemId].owner = payable(msg.sender);
    idToMarketToken[itemId].sold = true;


I think buyOne is dedicated to minting (aka first sale). I assume the NFT is available for sale on the website and this gets triggered by the front-end.

As far as I understand sellOne is for subsequent sales (which require the owner to approve the contract address). Here the transaction is triggered from the front-end when the buyer tries to buy. But obviously there is another feature in the front-end/website to put the NFT on sale (this really calls the standard setApprovalFor method from ERC721).

Hope this helps, even if I'm not sure this how things work, having not seen the front-end/website part.