Home Starknet fee reduction
Post
Cancel

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
0.8.00.05
0.11.00.01
0.13.00.005
0.13.10.0025

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.8.012.825.6  0.4 0.4
0.10.23.2102.451.2 1.6 0.8
0.11.00.6420.4810.2420.480.320.320.16
0.13.00.3210.245.1210.240.160.160.08
0.13.10.165.122.565.120.080.080.04

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.