【问题标题】:NFT Marketplace cards using ReactJS使用 ReactJS 的 NFT 市场卡
【发布时间】:2022-08-17 00:35:39
【问题描述】:

我是区块链的新手并正在努力学习,我创建了 NFT 市场应用程序,其中铸币、销售和购买等功能运行良好。但是,在出售后的 UI 中,所有铸造的 NFT 的 NFT 价格显示相同。我在代码中使用了 {Web3.utils.fromWei(String(price), \"ether\")}.120000 来显示 NFT 的价格,但它没有反映区块链的价格。 Click to view image

<CardContent className={classes.content}>
            <div className={classes.title}>
              <Typography
                className={\"MuiTypography--heading\"}
                variant={\"h5\"}
                gutterBottom
              >
                {name}
              </Typography>
              <Chip
                size=\"small\"
                disabled={true}
                label=\"Selling\"
                className={classes.badge}
              />
            </div>
<Typography variant=\"h6\" className={classes.price}>
              <SvgIcon
                component={EthereumLogo}
                viewBox=\"0 0 400 426.6\"
                titleAccess=\"ETH\"
              />
              <span{Web3.utils.fromWei(String(price), \"ether\")}.120000</span>
  </Typography>
  • 您在铸造 nft 时可能设置了相同的价格
  • 铸币时我没有设定任何价格。下面是铸币函数@Yilmaz function mint(string memory uri) public returns (uint256){ _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _safeMint(msg.sender, newItemId);批准(市场,newItemId); Items[newItemId] = Item({ id: newItemId, creator: msg.sender, uri: uri });返回新项目 ID; }
  • 如果您没有设置价格,您希望如何获得 nft 项目的价格?

标签: javascript reactjs blockchain solidity nft


【解决方案1】:

您需要先从市场合约中列出的资产中获取价格。请注意,NFT 合约和市场合约并不相同,它们是两段不同的代码。可能您从常数而不是从市场合同调用中获得价格。

【讨论】:

    猜你喜欢
    • 2022-06-15
    • 2011-09-19
    • 2022-11-12
    • 2016-11-01
    • 1970-01-01
    • 2016-05-10
    • 2023-03-03
    • 2011-01-31
    • 2016-11-05
    相关资源
    最近更新 更多