坚固 - 更新已部署合同中的时间戳值
我有一份拍卖合同,应该说20分钟。
为了促进这一点,我有一个AuctionEndTime
变量,我在构造函数
中初始化,如下所示:
auctionEndTime = block.timestamp + 20 minutes;
但是,如果我想通过添加AhauctionEnd Time
来更新还有一些额外的时间?
Ahaucterendtime
变量的额外分钟的价值,如下:
function changeAuctionEndTime(uint extraTimeAmount) public {
require(msg.sender == contractOwner, "ONLY THE CONTRACT's OWNER CAN CALL THIS FUNCTION!");
auctionEndTime += newEndTime minutes;
}
我写了一个
Expected ';' but got 'minutes'
函数,让我通过我想添加到我的 单词分钟下的红线
。 因此,显然不喜欢那里的东西。 (并注意此错误立即出现 - 作为IN,这不像我编译并获取此错误,而是我什至无法编译并运行代码。)
那是怎么回事?我该如何解决?
I have an auction contract that's supposed to run for say 20 minutes.
To facilitate this, I have an auctionEndTime
variable which I initialize in the constructor
as follows:
auctionEndTime = block.timestamp + 20 minutes;
But what if I wanted to update the auctionEndTime
by adding some additional minutes to it?
I wrote a function that lets me pass in the value of the additional minutes I'd wanna add to my auctionEndTime
variable, as follows:
function changeAuctionEndTime(uint extraTimeAmount) public {
require(msg.sender == contractOwner, "ONLY THE CONTRACT's OWNER CAN CALL THIS FUNCTION!");
auctionEndTime += newEndTime minutes;
}
But this immediately gives me the following error:
Expected ';' but got 'minutes'
And it's giving me a squiggly red line under the word minutes
.
So it's clearly not liking something right there. (And note that this error appears immediately - as-in, it's not like I compile and get this error, it's that I can't even compile and run the code as is.)
So what's going on? How do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
extratimeamount
而不是newendtime
。seconds
,分钟
,小时
,天
和Weeks
Weeks 之后文字数字可用于指定时间单位。 (来自官方文档)。extratimeamount * 1分钟
而不是extratimeamount分钟
。这是您的代码,可以根据上述点工作 -
extraTimeAmount
and notnewEndTime
.seconds
,minutes
,hours
,days
andweeks
after literal numbers can be used to specify units of time. (From official docs).extraTimeAmount * 1 minutes
instead ofextraTimeAmount minutes
.Here is your piece of code that will work as per above points -