Closed guidanoli closed 6 months ago
To be exact, by "fixed size" you mean the fixed 32-byte size. Otherwise, for example, uint64
is fixed size. But abi.encode
packs it to 32 bytes while abi.encodePacked
doesn't
To be exact, by "fixed size" you mean the fixed 32-byte size. Otherwise, for example,
uint64
is fixed size. Butabi.encode
packs it to 32 bytes whileabi.encodePacked
doesn't
Ouch, you're right!
📚 Context
There are places in our code base that use
abi.encodePacked
for fixed-size values. This is not necessary, asabi.encode
works just likeabi.encodePacked
for those values. Plus,abi.encode
is shorter.✔️ Solution
Replace
abi.encodePacked
withabi.encode
in those cases.