需要味觉。取决于不同的情况
我的情况是,我拥有免费的薄荷功能,就像发件人有3个项目免费薄荷,并尝试铸造5个项目,我想要求发件人只需支付2个项目。
它不起作用,我认为错误在这里:
int256 payableMints = int256(_mintAmount - freeMints);
if(payableMints < 0){
payableMints = 0;
}
if(payableMints > 0){
require(msg.value >= (cost * uint256(payableMints)));
}
else{
require(msg.value >= (freeMintCost * _mintAmount));
}
我做错了什么吗?
My case is I have item free mint functionality like if sender have 3 item free mint and trying to mint 5 item i want to ask sender to pay only for 2 items.
it doesnot works and I think error is here:
int256 payableMints = int256(_mintAmount - freeMints);
if(payableMints < 0){
payableMints = 0;
}
if(payableMints > 0){
require(msg.value >= (cost * uint256(payableMints)));
}
else{
require(msg.value >= (freeMintCost * _mintAmount));
}
am i doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道什么是
freemintCost
的类型,但是如果它是uint256
类型,例如,您需要将_mintamount
转换为uint256:i i测试了此代码并有效:
I dont know what is the type of
freeMintCost
but if it is auint256
type, for example, you need to convert_mintAmount
to uint256:I tested this code and worked: