Error: invalid utf8 byte sequence; invalid continuation byte
See original GitHub issueHi,
I am getting the following error whilst trying to parse
an event using ethers.js
interface
.
This event emits a string
, I assume this has something to do with the problem because before I added the string
to the event data emission there was no problem with parsing the log.
The event in solidity:
event LogExecutionFailure(
address indexed executor,
uint256 indexed executionClaimId,
address payable indexed user,
IGelatoTrigger trigger,
IGelatoAction action,
string executionFailureReason
);
My ethers script that throws the error:
const abi = [ "event LogExecutionFailure(address indexed executor, uint256 indexed executionClaimId, address indexed user, address trigger, address action, string executionFailureReason)"]
const iface = new ethers.utils.Interface(abi);
const topicExecutionFailure = ethers.utils.id(
"LogExecutionFailure(address,uint256,address,address,address,string)"
);
const filterExecutionFailure = {
address: "0x21F7908734A147e084DBEe58C616fd59CE2A0a02",
fromBlock: parseInt(searchFromBlock),
topics: [topicExecutionFailure]
};
const logsExecutionFailure = await provider.getLogs(
filterExecutionFailure
);
for (const log of logsExecutionFailure) {
const parsedLog = iface.parseLog(log);
....
ERROR throws here
}
Here is a link to the tx that emitted this event on 0x21F7908734A147e084DBEe58C616fd59CE2A0a02 on Kovan
As you can see the correct string (“ErrorTransferFromUser”) is shown as part of the event data on Kovan:
Please help me find out why my ethers
interface
throws when trying to parseLog(log)
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
UTF-8 Continuation bytes - unicode - Stack Overflow
A continuation byte in UTF-8 is any byte where the top two bits are 10 . They are the subsequent bytes in multi-byte...
Read more >How to solve UTF8 invalid byte sequence copy errors on a ...
Digging around the internet, I've seen that this is a pretty common problem. The common solution is to use the plain text format...
Read more >Unicodedecodeerror: 'utf-8' codec can't decode bytes in ...
When working with strings you may have encountered the error "UnicodeDecodeError: 'utf-8' codec can't decode byte X in position X: invalid ...
Read more >How to Fix Invalid Byte Sequences in UTF-8 - YouTube
What is Unicode?That's what we will talk about in this video!Unicode is a system for character encoding, this allows you to represent an ......
Read more >A client is getting an error: “Invalid byte sequence for encoding ...
The error messages: "Invalid byte sequence for encoding "UTF8": 0x00" signifies that probably a NULL value was inserted into Database.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(you might have to skip over 68 bytes instead of 36 to get past a string link too… Maybe try 68 before 36? I’m more confident in that number now that I think about it)
Update: This seems to have worked well!
I was able to use the string now in
ethers.js
This code does the trick now, as you prescribed.
Do you think this implementation is ok?
I left out this bit:
because I catch any evm exceptions during the decoding anyway.
Can you elaborate on this bit
revertReason.length % 32 == 4
, please? I dont quite get this sanity check. Why == 4?Thanks again for your great help.