Techniques for large amounts of on-chain computation

Hi. I know there is a limit to how much gas can be used by a call in a single transaction, and therefore a limit to the amount of work that can be done with the code. So, is there an accepted standard way to perform computation that goes beyond this limit?

My thinking is that it would need to be split up over multiple transactions and include some kind of secure hash to make sure that when the function is called to continue doing work, it needs a specific value to verify that it’s picking up from wherever the previous call left off.

It depends on the type and nature of computation. If it is for scientific computing, it is better to optimize the algorithms to a degree that the computing can be done cheaply on-chain.

My question is what is the best way to accomplish this if a contract absolutely must use more gas for a computation than the gas limit. I am aware that in most cases it is probably possible to optimize the computation, but the ability to go beyond the gas limit could enable some novel applications.

One way to solve this, as you mentioned, could be to split the procedure into multiple transactions. That would work if you can isolate the break apart the large computation you need.

Another option that might make more sense is to offload some of the computation to an external processor. Like an oracle.

You can maybe also look at different chains and L2s that offer different limitations that better fit what you’re looking to do.


I didn’t think about using an oracle. I looked it up and discovered that it’s called a “computational oracle”.

1 Like