Skip to content

Getting array data with parseLogs in ethers.js #3278

Answered by ricmoo
Mudloop asked this question in Q&A
Discussion options

You must be logged in to vote

Any parameter that is indexed, but it’s type cannot fit into 32 bytes, will be hashed and that is how it is stored on the blockchain.

If you need access to that data, you will need your event to include both the indexed and non-index version. For example, this is a common pattern (the string type doesn’t fit into 32 bytes, so this is the case even if the string is under 32 bytes long): event Foo(string indexed searchName, string name) and in solidity it would be called as emit Foo(name, name).

Logging topics cost an extra 375 gas and logging data costs extra gas for each byte; so the more data you log the more the tx will cost.

Does that make sense?

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Mudloop
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@ricmoo
Comment options

@typedarray
Comment options

@ricmoo
Comment options

@typedarray
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #3277 on August 16, 2022 02:53.