-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to deserialize event from ABI for usage in getLogs call #7
Comments
Heyo, absolutely, can you expand further on your problem? @pointtoken getLogs does not deserialize or decode Ethereum Log/Solidity event data. You need to do that with ethjs-abi. See this example: Look for the decodeLogItem method. You would enter the event method ABI object in question, then the log data. You can also use the decoder I believe:
But I haven't tried this approach with getLogs yet. If you are listening for events, have you tried ethjs-filter? That is for listening to events on chain. https://github.com/ethjs/ethjs-filter Note this module will be updated before DevCon3 to be stateless. Hope this helps. Please provide more information though. |
Hi - Thanks for the quick response. I first when down the path of using ethjs-filter, but it turns out that the infura nodes don't support that API call, but they do support getLogs, which turns out is really the right call. The problem is the behavior of the abi in ethjs as compared to web3. Say I have this solidity event:
If I use ethJS to serialize it and look at the options property it looks like this:
But if I use web3 to serialize it, it looks like this:
So there is something funky about the way ethjs is serializing events from the abi. I checked in a test.js file to this branch https://github.com/pointtoken/CLI/tree/event_abi_issue so you can repo. If you want to pull that branch. Just run
It should be clear what is going on. |
I guess I was expecting Ethjs to behave like Web3 in this manner, but maybe there is a different path? I looked briefly at the ethjs-abi code but at first glance it wasn't creating the expected object required by the getLogs call. |
I will look into this further. I'll need to check how logs are handled and then see which is actually correct. Obviously we should patch this asap. |
I created a pull request with a broken test in the ethjs repo, since that's where the issue is: ethjs/ethjs#5 maybe close this bug since it is now in two places? |
Hi Guys - Love the library. We are using it in several places as we continue to develop our decentralized reward and loyalty system. One thing we do is use you to call getLogs in order to query for events on the blockchain, which is how we store achievements on chain. However, try as we might we could not successfully serialize our event from the ABI such that it could be passed to your getLogs call and we had to resort to Web3 as you can see below:
It would be really cool to use your stuff only and not have to pull in Web3. The ABI created from your code works great for everything else. Any ideas?
The text was updated successfully, but these errors were encountered: