5 如何用自己铸造的ERC20代币去交易自己铸造的ERC721的NFT代币

求指教,非常感谢

请先 登录 后评论

最佳答案 4天前

下面的方法简单示意了使用 amount 个 erc20 代币从合约中购买 tokenId 的 NFT:

function buyNFT(uint amount, uint tokenId) public {

    erc20.transferFrom(msg.sender, address(this), amount);

    nft.safeTransferFrom(address(this), msg.sender, tokenId);

}

其实只需要使用分别使用 ERC20 和 ERC721 的 transfer 功能。

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,112 浏览
  • RayLaruki 提出于 4天前

相似问题