Home Starknet fee reduction

Starknet fee reduction

Multiple factors go into calculating transaction fees on Starknet. The biggest one - use of storage - is going to be addressed by 4844 in a couple of days and by additional measures later this year.

The second major factor is the number of Cairo steps and builtins used. The heavier the computation a contract does, the more steps and builtins it consumes. A simple ERC20 transfer uses 1613 steps, 4 Pedersen and 47 range check builtins; an attack action in Loot survivor is roughly 82K steps and almost 6900 range check builtins. As we can see, in complex, computationaly intensive operations these calculations become a significant part of the whole transaction cost.

It’s a good thing then that the gas cost per step and builtin has been steadily decreasing over the past 2 years.

First, let’s compare the gas per step evolution:

Starknet versiongas / step

Version 0.8.0 was released on Mar 14, 2022. Version 0.13.1 is scheduled to hit mainnet almost exactly 2 years later, Mar 12, 2024. During this period, the StarkWare team has managed to reduce the gas per step 20 times. That’s huge!

At the same time, the cost of builtins has also been going down, as denoted by the following table:

Starknet versionbitwiseECDSAEC_OPkeccakPedersenPoseidonrange check  0.4 0.4 1.6 0.8

The cost of the range check builtin, which is used pretty much every time a numerical operation is done on Starknet, has decreased 10x in these past 2 years.

As an example, the aforementioned attack function got ~14x cheaper thanks to these reductions. Curiously, Loot Survivor is a single storage var game, so there’s no other way to make the game cheaper besides paying less for computation.

There’s better news still. With stuff like dynamic layouts and further improvements of the VM architecture, we can expect even more fee reduction in the future. Don’t be afraid to build computationaly complex functions on Starknet, they are only going to get cheaper.

This post is licensed under CC BY 4.0 by the author.