如何为智能合约添加创建的一个?
我正在为患者记录编写智能合约。但数据将采用时间序列数据格式。我想我应该为此添加created_at 字段。但我不知道具体该怎么做。
我对这份工作还很陌生。你能帮助我吗?
您可以看到结构体的一部分:
struct Patient {
string name;
uint16 age;
//max of uint16 is 4096
//if we use uint8 the max is uint8
string telephone;
string homeAddress;
uint64 birthday; //unix time
string disease; //disease can be enum
Gender gender;
}
I'm writing a smart contract for patient records. But the data will be in time-series data format. And I guess I should add created_at field for that. But I don't know exactly how to do this.
I'm pretty new at this job. Can you help me?
You can see part of the struct:
struct Patient {
string name;
uint16 age;
//max of uint16 is 4096
//if we use uint8 the max is uint8
string telephone;
string homeAddress;
uint64 birthday; //unix time
string disease; //disease can be enum
Gender gender;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
block.timestamp
为具有当前块时间戳作为秒的关键字,因为unix epoch包括您的事务。有关 block.timestamp 在这里。
您必须将
Createat
变量设置为结构:然后您必须将此语句用于设置此变量:
智能合约代码的示例:
You can use the
block.timestamp
keyword for have current block timestamp as seconds since unix epoch which your transaction is included.More information about block.timestamp here.
You must to set your
createdAt
variable into a struct:And then you must use this statement for set this variable:
Example of smart contract code: