OpenSea允许用户买卖NFT。在OpenSea中,您可以查看项目中列出的NFT的价格。当NFT被列出时,列出的价格是存储在区块链上,还是静态地存储在OpenSea的平台上?最终,我正在寻找一种方法,以刮价格上市的令牌在任何NFT项目。虽然我可以直接从OpenSea的网站上抓取,但是NFT数据被延迟加载,这使得直接从OpenSea.io抓取数据的过程更加复杂--我不希望使用selenium。
tl;dr :在不使用OpenSea的情况下,有什么方法可以确定项目中NFT令牌的价格吗?
发布于 2022-03-04 20:45:46
通常人们都是通过OpenSea网站“懒散”和“列表”的,这意味着它不是链上的;你会在OpenSea上看到元数据对于几乎所有上市出售的NFT来说都是“可编辑的”。下面是一个例子:
OpenSea上市:人名名单的以太扫描地址:(注:没有在线事务).你刮擦的范围是多少?最好的选择可能是通过OpenSea API?https://docs.opensea.io/reference/api-overview。
发布于 2022-05-07 18:00:48
上市价格不同于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函数中包含了与您的问题相关的部分。
https://stackoverflow.com/questions/71330857
复制相似问题