0

I was doing a project, and I have an event

event AddedDoctor(
        address indexed doctorAddress,
        string indexed name, 
        string indexed doctorRegistrationId,
        uint256 dateOfRegistration,
        string specialization,
        address hospitalAddress
    );

I am not able to access all the parameters of this event to index it is The Graph. I am facing two issues :

  1. string indexed name parameter is indexed so it is accessible by event.params.name but it is in the Bytes format. On searching the net I found that indexed strings or arrays are stored as hashes and not plain strings. How do I get unstuck.
  2. I am not able to read unindexed parameters string specialization and address hospitalAddress using event.params.specialization and event.params.hospitalAddress. How do I access these unindexed parameters?

Basically I want to index all these event parameters in The Graph for easy retrieval of data. How can I do that?

1 Answer 1

0

I found that The Graph can index the unindexed string parameter in the string format and we can directly work with that. The indexed string parameters are hashed into into 20 bytes object which is difficult to work with. I found this answer:

Indexed Event with string not getting logged

So, basically I removed indexed keyword from all the parameters of string or array type and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.