How To Save 50% on Gas Costs
- π»Tutorials
- π€
- βIntermediate
- π·οΈ
- π 4 years ago
When we built the first version of Goldfinch, we did not really pay attention to gas costs. This resulted in even basic actions being insanely expensive on our protocol.
When we built the first version of Goldfinch, we did not really pay attention to gas costs. This resulted in even basic actions being insanely expensive on our protocol. Borrowing money cost $250+ at high gas times π. So the first improvement we made was to see how we could reduce gas costs. We spent hours profiling, researching, and going through our code, more or less line by line, to figure out how we could cut gas. Along the way we learned a lot of really useful rules of thumb. These are high level concepts you can always keep in the back of your mind while writing Solidity, both for what adds gas, and what doesnβt add gas, which is not always intuitive. Following these, we were able to cut costs of most functions by 30β50%, without sacrificing much in terms of readability.