[英]How do I get the Price an NFT sold (sells) for via the base NFT contract in solidity?
I'm trying to figure out how to get the highest price and NFT sold (sells) via the base NFT contract in solidity.我试图弄清楚如何通过基础 NFT 合约以稳固的方式获得最高价格和 NFT 出售(出售)。 So, I can possibly map the highestSoldPrice to a TokenId within the collection.
所以,我可以将highestSoldPrice 映射到集合中的TokenId。
I'm sure there's a clever way to do this.我确信有一个聪明的方法可以做到这一点。
Thank you and God Bless谢谢你,上帝保佑
EDIT:编辑:
Base contracts as in the contract that deploys the NFTs, it would inherit the ERC721 contract.与部署 NFT 的合约一样,基础合约将继承 ERC721 合约。
We don't have much information about what your talking about, like are you talking about the base ERC721 contract?我们没有太多关于你在谈论什么的信息,比如你在谈论基础 ERC721 合同吗? is it the marketplace contract?
是市场合同吗? is the architecture of the marketplace contract ERC1155?
市场合约 ERC1155 的架构是什么? No clue
没有线索
Since your talking about highest price and NFT Sold , im assuming your talking about the Marketplace contract.由于您谈论的是最高价格和已售出的 NFT,我假设您谈论的是市场合约。
Solutions解决方案
If your going with your own script with node provider check out this github for reference :>如果您使用自己的脚本与节点提供者一起使用,请查看此 github 以供参考:>
uint public highestPrice=0 // initially
mapping(uint->string) public highestSoldNft
When you mint the token, you pass the price as a parameter当您铸造代币时,您将价格作为参数传递
function mint(string memory tokenUri, uint price) public payable returns(uint){
_safeMint(msg.sender,newTokenId);
// after minting update the mapping
if (price > highestPrice){
delete highestSoldNft[highestPrice]
setHighestPrice(price)
setHighestSoldNft(tokenUri,price)
}}
function setHighestPrice(uint price) public private {
highestPrice=price
}
function setHghestSoldNft(string memory tokenUri,uint price) public private{
highestSoldNft[price]=tokenUri
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.