Posts

Showing posts from January, 2022

Solidity Gas Optimisation

Image
If you are familiar with a language like JavaScript, you tend to never think about how your variable is stored, except to deal with the scope of the variable. When you are making programs to run on a distributed system like a blockchain, you have to think about things a bit differently. Solidity works as a compiled language where each operation gets converted to a lower level opco which the EVM can understand an interpret. Every operation that you write on your program gets executed on every computer in the network, which is why every operation costs 'gas' to prevent spamming and infinite loops. In solidity, getting to know the machine readable operations and their associated cost literally saves you money. Gas optimization is a challenge that is unique to developing Ethereum smart contracts. To be successful, we need to learn how Solidity handles our variables and functions under the hood. Some of the techniques we cover will violate well known code patterns. Before opt...