简体   繁体   English

智能合约中每次铸币的审批系统

[英]Approval system for each minting in smart contract

I am new to blockchain application development and trying to create a smart contract in ERC 721. Currently, I implement a system with the help of a database where minting is only possible by the owner.我是区块链应用程序开发的新手,正在尝试在 ERC 721 中创建智能合约。目前,我在数据库的帮助下实现了一个系统,其中只能由所有者进行铸造。 In that case, I take the fee from the user and save the transaction hash to the database.在那种情况下,我从用户那里收取费用并将交易 hash 保存到数据库中。 If the owner thinks all information is correct then the owner will mint this NFT from the owner's wallet to the user's wallet.如果所有者认为所有信息都是正确的,那么所有者将把这个 NFT 从所有者的钱包铸造到用户的钱包。 But the problem, in this case, is that gas fee has to be paid twice.但问题是,在这种情况下,gas 费必须支付两次。

As far as I know, minting can be done from that address if the owner approves it beforehand.据我所知,如果所有者事先批准,可以从该地址进行铸造。 But I want to do it a little differently.但我想做一些不同的事情。 Eg - I wanted to implement an authorization system for each minting.例如 - 我想为每次铸造实施授权系统。 That is, when the user mints an NFT, it will wait for the approval.也就是说,当用户铸造一个 NFT 时,它会等待批准。 It will be minted if the owner approves it.如果所有者批准,它将被铸造。 Is it really possible?真的可能吗?

Any suggestions would be highly appreciated!Thank you任何建议将不胜感激!谢谢

I think you could use a whitelist approach我想你可以使用白名单方法

Maybe you could achieve the same user flow by creating a database where each time a user request a mint you store their wallet address.也许你可以通过创建一个数据库来实现相同的用户流程,每次用户请求铸币时,你都会存储他们的钱包地址。

Then your 721 contract can have a whitelist logic where the owner would add all the "approved" user wallet addreses.然后你的 721 合约可以有一个白名单逻辑,所有者可以在其中添加所有“已批准”的用户钱包地址。

And finally the user will need to interact with your 721 contract to mint their token.最后,用户将需要与您的 721 合约进行交互以铸造他们的代币。

This solution still does not fix the gas being paid twice.这个解决方案仍然没有解决 gas 被支付两次的问题。

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM