'NFT List Prices

OpenSea allows users to buy and sell NFTs. From OpenSea, you can view the prices of listed NFTs within a project. When an NFT is listed, is the listed price stored on the block chain or is it statically stored only on OpenSea's platform? Ultimately, I am looking for a way to scrape the prices of listed tokens within any NFT project. While I could scrape directly from OpenSea's website, NFT data is lazy loaded which complicates the process of scraping directly from OpenSea.io - I do not wish to use selenium.

tl;dr : Is there any way to determine the price of an NFT token within a project without using OpenSea?



Solution 1:[1]

Typically people are "lazy minting" and "listing" via OpenSea website, which means it's not on-chain; you will see on OpenSea that the metadata is "editable" for almost all NFTs listed for sale. Here's an example:

OpenSea listing: Etherscan address for the person listing: (note: no on-chain transactions). What's the scope of your scraping? Best bet may be to pull via the OpenSea API? https://docs.opensea.io/reference/api-overview

Solution 2:[2]

Listing price is different from nft price. Listing price is the fee that you pay for the marketplace. Otherwise everyone would list nft for free and that would cause extra load on the contract and server of website.

When you write an Nft contract, you specify the listing price as:

  uint public listingFee=0.025 ether;

Logically listingFee must be on chain since the nft creators are directly interacting with the smart contract.

Price of nft is different. When you create an Nft item, you define a struct:

struct NftItem{
    uint tokenId;
    uint price;
    address creator;
    bool isListed;
  }

To create an Nft item, define a function:

function _createNftItem(uint tokenId,uint price) private{
    require(price > 0, "Price must be at least 1 wei");
     // you need to store nft's in a mapping id=>Nft
    _idToNftItem[tokenId]=NftItem(
      tokenId,
      price,
      msg.sender,
      true
    );
    // you could emit an nft created event here
  }

Price of Nft is determined by you on the fly when you submit the form to create the nft. since nft's are going to be stored on chain as struct, it will include the price

Now you call the mint function:

function mintToken(string memory tokenURI,uint price) public payable returns (uint){
    // make sure you dont mint same uri again
    require(!tokenURIExists(tokenURI),"Token URI already exists");
    // this is where you make sure sender is paying the listig price to use the platform
    // this is one time fee. so you can create a mapping and keep track of msg.senders here as bool if they paid the listing price or not
    // if they did not pay, you require them to pay
    require(msg.value==listingFee,"Price must be equal to listing fee");
    .. more logic here
    _usedTokenURIs[tokenURI]=true;
    return tokenIdOfNewlyCreatetNftItem;
  }

I just included the parts that related to your question in mint function.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brad Kirby
Solution 2 Yilmaz