#When to bump the storage?

1 messages · Page 1 of 1 (latest)

worldly drift
#

Hey guys,
I'm new to Soroban and i'm trying to learn, I'm solidity developer (5 years). I was checking the token example https://github.com/stellar/soroban-examples/tree/v0.9.2/token , and I notice that storage is bumped in each function read or write.
It might make sense that you are bumping it in write operation ( approve , transfer, etc,) but in read operation ? as far as i understand , bumping includes " paying" and modifying the state , which makes the function no longer read. Please feel free to correct me . Thanks for your help and for taking the time to read this in advance.

GitHub

Example Soroban Contracts. Contribute to stellar/soroban-examples development by creating an account on GitHub.

jade meadow
#

Coming from solidity something that you might get wrong with soroban is the idea of a "read" (view) function. That's not something that exists in Soroban, with soroban you pay fees every time you introduce a transaction into the network no matter if there was or not an update in the storage of a contract.

When to bump it? That depends with the traffic of your contract so is something you need to calculate. In the case of a token contract it makes sense to pay for it every time is read because it means (or in most of the cases) that the owner of that balance is using it so it pays to keep it available

worldly drift
native shard
#

Soroban does have simulated transactions though. You can simulate transactions off-chain, using real data from the chain, to perform free read and write operations. The soroban-rpc provides this functionality.

fringe horizon
native shard
#

When simulating, the write operations will be free too, but they won't actually write to the network because they're simulated. But if you have a function that writes data, you can simulate it to understand what it's outcomes are.