简体   繁体   English

合约创建者的 Solidity NFT 铸造费?

[英]Solidity NFT Minting Fees to Contract Creator?

I am currently trying to program an ERC721 smart contract in Solidity, allowing users to mint from it.我目前正在尝试在 Solidity 中编写 ERC721 智能合约,允许用户从中铸造。 But with every mint, I want the user to pay a fee to a specified wallet.但是对于每一个铸币厂,我都希望用户向指定的钱包支付费用。 How can I achieve this?我怎样才能做到这一点? Any help ist greatly appreciated, thanks in advance!非常感谢任何帮助,在此先感谢!

First you declare de variable as an address payable where you will store the address that will recieve the fees payments, then in the constructor you receive the address as a param and store it in the variable you previously defined then首先,您将 de 变量声明为应付地址,您将在其中存储将接收费用的地址,然后在构造函数中将地址作为参数接收并将其存储在您之前定义的变量中

You have to make the mint function payable, then inside of the mint function a require like this require(msg.value == mintfee, "some error message in case the ether is not the especified amount");您必须使铸币厂 function 应付,然后在铸币厂 function 内部像这样require(msg.value == mintfee, "some error message in case the ether is not the especified amount"); or if you want to put a minimun and not an exact amount require(msg.value >= mintfee, "some error message in case the ether is not the especified amount");或者如果你想输入一个最小值而不是一个确切的数量require(msg.value >= mintfee, "some error message in case the ether is not the especified amount"); , now you can pay the fees like this , 现在你可以像这样支付费用了

(bool result,) = variableWhereYouStoreTheAddress.call{value:msg.value}("");
revert(result,"the fees payment has failed");

暂无
暂无

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

相关问题 铸造 nft 后 NFT 合约余额没有增加 - NFT contract balance not increasing after minting nft 如何使用铸币费创建智能合约 - how to create smart contract with minting fees Solidity - 在测试合约时签署铸币 - Solidity - Signing minting while testing a contract 在solidity智能合约中管理gas费用 - Managing gas fees in solidity smart contract 将版税添加到 Solidity NFT 智能合约 - Add Royalty to solidity NFT smart contract 以太坊 Solidity NFT 合约执行过程中遇到错误 [Out of gas]? - Error encountered during Ethereum solidity NFT contract execution [Out of gas]? 在安全帽上部署合同或创建 NFT 时出现错误:ProviderError: invalid sender - On hardhat when deploying a contract or minting an NFT getting error: ProviderError: invalid sender Solidity:如何将一组地址从一个合约(NFT)传递到另一个合约(非 NFT)以备后用? - Solidity: How to pass an array of addresses from one contract (NFT) to another one (not NFT) for later use? Solidity:从 Marketplace 合约调用 NFT 合约的一个函数,只有 Marketplace 有权调用它 - Solidity: call a function of NFT contract from Marketplace contract, and only Marketplace has access to call it 如何在您通过智能合约以编程方式铸造的 NFT 中包含“由...创建”信息(例如,在 OpenSea 列表中) - How to include "Created by..." information (e.g. on the OpenSea listing) on an NFT that you're minting programatically through a smart contract
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM