B009: EVM Tricks

Native Data Types

The word size of the EVM is 256-bits, meaning that all instructions within its system are “optimized” to operate with 256-bit / 32-byte data types. Any data type specified below this range is implemented at a non-native level by introducing surplus instructions, such as bitwise shifts and bound checks.

Seemingly Optimized Pattern

Variable Tight-Packing

Although briefly mentioned in B-003, this mechanism warrants a little bit more of an explanation to be better comprehended as to when it should be utilized and when it is detrimental to do so.

Hidden Gas Costs

The gas cost of each EVM instruction differs depending on its original purpose and on the “complexity” it bears to execute it. A relatively up-to-date table of instructions paired with their gas costs can be found maintained by X here.

1inch: Example of CALLVALUE Optimizations
Example of Access Control Optimization


While intimidating at first glance, the EVM is a relatively elementary machine that can be skillfully handled to operate to one's benefit. Although we only grazed its surface, it is evident that there are a lot of “hidden” or at least not widely-discussed notions and caveats one should tread when developing applications on this platform.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store