我正在做一个项目,我有一个事件
event AddedDoctor(
address indexed doctorAddress,
string indexed name,
string indexed doctorRegistrationId,
uint256 dateOfRegistration,
string specialization,
address hospitalAddress
);
我无法访问此事件的所有参数来索引它是The Graph
。我面临两个问题:
string indexed name
参数被索引,因此event.params.name
可以访问它,但它是Bytes
格式的。在网上搜索时,我发现索引字符串或数组存储为散列,而不是纯字符串。我该如何摆脱困境- 我不能使用
event.params.specialization
和event.params.hospitalAddress
读取未索引的参数string specialization
和address hospitalAddress
。如何访问这些未编制索引的参数
基本上,我想在The Graph
中对所有这些事件参数进行索引,以便于检索数据。我该怎么做?
我发现The Graph
可以以字符串格式索引未索引的字符串参数,我们可以直接使用它。indexed
字符串参数被散列成20字节的对象,这很难处理。我发现这个答案非常有用:
https://ethereum.stackexchange.com/questions/6840/indexed-event-with-string-not-getting-logged
所以,基本上我从string
或array
类型的所有参数中删除了indexed
关键字,它就起作用了。