Move.

帖子

分享您的知识。

doodee.
Apr 01, 2025
专家问答

Can you get a timestamp when an object is created in Move?

Hey there! I'm working with Move and I'm curious if it's possible to get a timestamp of when an object is created. I've seen something about using sui::clock to capture this, but I was wondering if there's a native way to access this timestamp directly in Move code without additional attributes or if we can avoid additional computations. Any insights?

  • Move CLI
  • Move
2
2
分享
评论
.

答案

2
elfDani.
Apr 1 2025, 14:19

您可以使用 sui:: clock 将对象创建期间的时间戳作为属性捕获,例如 timestamp_ms. 此方法涉及添加一个属性来存储共享时钟对象中的 “time_ms”.

1
评论
.
YJS.
YJS94
Apr 1 2025, 14:52

本质上不支持直接在 Move 中访问时间戳而不添加属性. 最好的方法似乎是使用共享的Clock对象或在创建后引用交易数据.

1
评论
.

你知道答案吗?

请登录并分享。

Move is an executable bytecode language used to implement custom transactions and smart contracts.

148帖子231答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。

我们使用 cookie 确保您在我们的网站上获得最佳体验。
更多信息