A contract with a large amount of data

Hi, I have a question, which is what to do when the contract has a lot of data
For example, what if the AEX9 contract captures all the account balances? What if there are too many or even millions of accounts for the program to handle?

Actually this is same as building a staking contract.

I think this should be possible. I am yet not there to help you but perhaps

@dimitar.chain can put his thoughts

I’d summon the professionals there @hanssv.chain and @philipp.chain

1 Like

If you think of the block chain as a (very slow) computer, and your contract as a program running on this computer the problem might become easier?! When you write a program solving a task and the program does not fit the resources of your computer you have three options basically - 1) buy a beefier computer (not really an option here), or 2) restructure your task/problem, or 3) use a more efficient algorithm.


The problem with the existing AEX9 protocol seems to be that if it runs for a long time, the call gets the account balance, and the data is huge

map operations have static execution time, AEX-9 doesn’t require more computation with more accounts present


Example: Call a


method, if the user is in the hundreds of thousands of cases, the returned data will be super large, will create a ton

balances is not statful and thus doesn’t need to be called on-chain, but can be fetched using a dry run.

also you are not forced to use balances if you don’t need it, you can keep track of balances for each account separately or keep track of contact events iteratively.


Ok, I see. Thank you

1 Like