NFT 标价

发布于 2025-01-11 09:11:08 字数 274 浏览 0 评论 0原文

OpenSea 允许用户买卖 NFT。从 OpenSea 中,您可以查看项目内列出的 NFT 的价格。当 NFT 上市时,上市价格是存储在区块链上还是仅静态存储在 OpenSea 平台上?最终,我正在寻找一种方法来降低任何 NFT 项目中上市代币的价格。虽然我可以直接从 OpenSea 的网站上抓取数据,但 NFT 数据是延迟加载的,这使得直接从 OpenSea.io 抓取的过程变得复杂 - 我不希望使用 selenium。

tl;dr:有没有办法在不使用 OpenSea 的情况下确定项目中 NFT 代币的价格?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一瞬间的火花 2025-01-18 09:11:08

通常人们是通过 OpenSea 网站“懒惰铸币”和“上市”,这意味着它不是在链上的;您将在 OpenSea 上看到,几乎所有列出出售的 NFT 的元数据都是“可编辑的”。这是一个示例:

OpenSea 列表
列出人员的 Etherscan 地址:(注意:无链上交易)。你的抓取范围有多大?最好的选择可能是通过 OpenSea API 拉取? https://docs.opensea.io/reference/api-overview

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

眼藏柔 2025-01-18 09:11:08

挂牌价格与nft价格不同。挂牌价格是您为市场支付的费用。否则大家都会免费上架nft,这会对合约和网站服务器造成额外的负担。

当您编写 NFT 合约时,您将挂牌价格指定为:

  uint public listingFee=0.025 ether;

逻辑上 listingFee 必须在链上,因为 NFT 创建者直接与智能合约交互。

nft的价格不同。创建 Nft 项目时,您需要定义一个结构体:

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

要创建 Nft 项目,请定义一个函数:

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
  }

Nft 的价格由您在提交表单以创建 Nft 时动态确定。由于 nft 将作为结构存储在链上,因此它将包含价格

现在您调用 mint 函数:

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;
  }

我刚刚在 mint 中包含了与您的问题相关的部分功能。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文