Outcome of sload() read string is weird

Why does the data I read using the sload() function in assembly for reading string not match what I have stored? how to read the data of string in the right way by using assembly?
My string is storing a link, but what I read is like 0x000….0ed.

If you're looking for an answer to the question "why isn't my code working correctly?"...

Then it might be wise to actually post your code here!

1 Like

You need to first calculate the slot where this string is stored, and then use sload(slotNumber) to read the content of that slot. If the length of the string is less than 31 bytes, the slot will contain both the string content and its length. If the string length exceeds 31 bytes, the slot will only store the string's length, and the string content will be stored at keccak256(slotNumber). If the string's length exceeds the storage capacity of one slot, it will continue to be stored at keccak256(slotNumber) + 1 and so on.

1 Like

Thank you for BCA useful advice! (BTW it's a person or a team?)