August 2019
Intermediate to advanced
486 pages
13h 52m
English
In the Ethereum blockchain, every contract deployment and transaction consumes gas. The gas is paid in ether and has an economic value. When you deploy a contract, the compiled code is sent to the blockchain. The bigger the contract code is, the more gas units it consumes when deployed. It is recommended that the contract should be compiled with optimization flag enabled. Enabling optimization might optimize the code size and consume less gas units when deployed. Sometimes, the optimized contract also consumes less gas units when their function is called.
You can also look at the Economic patterns section in Chapter 13, Solidity Design Patterns, to learn some special cases where gas consumption could be optimized.