Closed patitonar closed 5 years ago
Could you please add the complete example?
Created a simple example on this repo https://github.com/patitonar/test-web3-getPastEvents
On master
branch using version 1.0.0-beta.50
is failing.
On working-example
branch using version 1.0.0-beta.47
is working without errors.
Will test and if required fix it asap.
Reproduced this same issue on 1.0.0-beta.50
, working on 1.0.0-beta.39
I have also just seen this when updating web3js, previous version 1.0.0-beta-37
- also can confirm this worked as expected on 1.0.0-beta.47
This got fixed with https://github.com/ethereum/web3.js/commit/2ce2412daea89c3fa90fa2f589617e514602ac40 and will be released today.
I seem to be getting this same error when calling myContract.methods.myMethod(...).send()
for a method that has no return value. It appears the transaction does get sent but the .then()
never fires and this error is thrown.
I could be missing something though, I'm currently knee deep in upgrading from 1.0.0-beta.34
to 1.0.0-beta.52
, which has been a challenge to say the least.
I was having the same error after upgrading to 1.0.0-beta52
and using web3.eth.abi.decodeLog
.
The error message shows when the receipt's data field is '0x', and this value is passed to decodeLog for the data argument. When I set the data value to null
it works fine.
May I suggest updating web3.eth.abi.decodeLog the same way it was done for EventLogDecoder ? https://github.com/ethereum/web3.js/blob/2ce2412daea89c3fa90fa2f589617e514602ac40/packages/web3-eth-contract/src/decoders/EventLogDecoder.js#L50-L52
Thanks!
@hqblock, good catch! When I update web3.eth.abi.decodeLog with the same change on line 232, I can actually submit my transaction now:
if (data && data !== '0x' && data !== '0x0') { ... }
Note that, in my specific use case, checking for 0x0
was also necessary. ~I still can't get logs for a contract using web3.eth.contract.getPastEvents
(I just get an empty list?) and I think that may also be related to log decoding somehow... still digging around.~
UPDATE: the getPastEvents() error I mentioned was unrelated and caused by my own stupidity. However, I'm pretty sure updating web3.eth.abi.decodeLog
as @hqblock suggested is a good idea! ~I'll try to put together a PR.~ See #2686
The correct if is:
if (data && data !== '0x') {
....
}
0x0 should be handled as 0 or false.
@nivida Okay, I figured out what my issue was with decodeLog
- it's something different than just the "empty data" check. I will create a separate issue since adding to the comments of this closed issue seems inappropriate.
See: #2695
Description
I got this error when getting the events in the following code
The abi of the event:
Error Logs
Versions