This forum is a read-only archive. Posting, replying and signing in are disabled.

Dealing with max size of stateful contract

gidon

When I first designed my application, I didn’t realise there was a maximum size of 700 for a stateful contract. One solution is to split up the contract into multiple and read the others’ states when needed.

Are they any patterns or best practices I should be aware of when dividing the application?

One idea is that since my app supports different functions (NoOp with string arg specifying intended action), I can then have a master contract and then one contract for each function. The master contract would then verify that a NoOp call with a string transaction is grouped with a call to its asociated contract. This may make handling state a bit complicated if there is shared state that multiple functions want to write to - in which case it would have to be handled in the master contract.

Are there any other solutions which may be more appropriate?

✔ Solved by fabrice in post #2
edited
fabrice

Actually stateful TEAL is limited to 1kb of size, but 700 of “cost”: The Smart Contract Language - Algorand Developer Portal

I don’t think there are official guidelines on the best way to split a smart contract.

If you need to run operations with higher cost, you may consider grouping the smart contract call with 0-Algo transaction from stateless smart contract accounts. (You will then need also to have a mechanism to pay for the fees that these stateless smart contract transactions use.)