Skip to content

Decoding a struct from provider.getStorageAt #2373

Answered by scherroman
bmateus asked this question in Q&A
Discussion options

You must be logged in to vote

I've also been wondering the same thing. I couldn't find a single example of decoding a packed storage slot value anywhere, either for ethers.js, web3.js or otherwise. Closest article I found was here but they don't show their work for the packed slot example. Seems like a pretty important thing to be able to do easily to audit smart contracts that make certain storage variables internal/private, which are often important to the behavior of the contract.

I couldn't get this to work with decode as it appears to assume the hex value is unpacked, whereas in reality some slot values are packed when neighboring data types are small enough, like in your example above. I discovered the default e…

Replies: 2 comments 3 replies

Comment options

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

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

@scherroman
Comment options

@ricmoo
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