[英]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.