In my code, when accessing a struct from a mapping, I sometimes do something like:
myStructs[msg.sender].text = "foo"
and this works fine
Is there any security implications in accessing and modifying my state variables this way??
Oct 22, 2022, 1:21 AM
I would say you should just remember to validate the permissions if you are mutating data inside the storage. If you lack proper requirements for modifying anything, you could potentially end up with an exploit. From experience, that's not something fun and you should test toroughly every piece of code hahahaha
Oct 22, 2022, 1:26 AM
I think that's what people usually do.
or
StructName storage senderStruct = myStructs[msg.sender];
senderStruct.text = "foo";
Most likely the pattern above is used for gas optimization.
or
StructName storage senderStruct = myStructs[msg.sender];
senderStruct.text = "foo";
Most likely the pattern above is used for gas optimization.
Oct 22, 2022, 6:07 AM
I think I do have the required permissions before a user can execute any of those functions
So my chosen method isn't gas optimal?
I'll be happy to restructure my code
It's like a 100 lines or less short, shouldn't be much of a hassle 🙂
I'll be happy to restructure my code
It's like a 100 lines or less short, shouldn't be much of a hassle 🙂
Oct 22, 2022, 8:05 AM