Relations Modules

建立关系索引的方式

5Degrees协议考虑到存储费的问题,所以链上没有存储完整的关系网络,需要链下进行数据维护。完全遵循EIP1155协议,可通过 TransferSingle 和 TransferBatch 事件进行快速索引数据建立起完整的关系网络数据。

TransferSingle()

event TransferSingle(address indexed operator, address indexed from, 
address indexed to, uint256 id, uint256 value)

当mint时(即关注),from为 address(0) ,to 为 关注者,id 为被关注者的地址序列化(反序列即是被关注者地址)。

当burn时(取消关注),from为关注者,to为 address(0),id 为被关注者的地址序列化(反序列即是被关注者地址)。

注:value恒定为1。

TransferBatch()

event TransferBatch(address indexed operator, address indexed from, 
address indexed to, uint256[] ids, uint256[] values)

ids 为被关注者的地址序列化集合(反序列即是被关注者地址集合)。

Last updated