Courses

Optimizing Performance on Polygon
Polygon · Chapter 13

Optimizing Performance on Polygon

A simple, predictable contract is often a good starting point for performance. Measure gas use before making changes, and keep correctness ahead of tiny savings.

The basics

  • Writing persistent storage costs work. Avoid saving data that the contract does not actually need.
  • A loop over an ever-growing list can eventually use too much gas. Prefer bounded operations or smaller batches.
  • Lower fees on Polygon do not remove execution limits. Measure on your target network and avoid unnecessary frontend RPC polling.

Try it yourself

Compare a design that stores every click with one that only stores a total count. Which information does your app need onchain? Explain the tradeoff before changing the code.

Read more in the official documentation

@ Daniel Burlacu