# Techniques for large amounts of on-chain computation

**URL:** <https://forum.soliditylang.org/t/techniques-for-large-amounts-of-on-chain-computation/1525>\
**Category:** Code Wizards\
**Created:** [March 4, 2023, 9:38pm UTC](https://forum.soliditylang.org/t/techniques-for-large-amounts-of-on-chain-computation/1525 "2023-03-04T21:38:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikebolt](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/mikebolt/32/742_2.png) [@mikebolt](https://forum.soliditylang.org/u/mikebolt)\
**Post date:** [March 4, 2023, 9:38pm UTC](https://forum.soliditylang.org/t/techniques-for-large-amounts-of-on-chain-computation/1525/1 "2023-03-04T21:38:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maxareo](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/maxareo/32/276_2.png) [@maxareo](https://forum.soliditylang.org/u/maxareo)\
**Post date:** [March 5, 2023, 3:25am UTC](https://forum.soliditylang.org/t/techniques-for-large-amounts-of-on-chain-computation/1525/2 "2023-03-05T03:25:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mikebolt](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/mikebolt/32/742_2.png) [@mikebolt](https://forum.soliditylang.org/u/mikebolt)\
**Post date:** [March 5, 2023, 8:41pm UTC](https://forum.soliditylang.org/t/techniques-for-large-amounts-of-on-chain-computation/1525/3 "2023-03-05T20:41:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![toledoroy](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/toledoroy/32/680_2.png) [@toledoroy](https://forum.soliditylang.org/u/toledoroy)\
**Post date:** [March 8, 2023, 5:46pm UTC](https://forum.soliditylang.org/t/techniques-for-large-amounts-of-on-chain-computation/1525/4 "2023-03-08T17:46:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mikebolt](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/mikebolt/32/742_2.png) [@mikebolt](https://forum.soliditylang.org/u/mikebolt)\
**Post date:** [March 13, 2023, 8:55pm UTC](https://forum.soliditylang.org/t/techniques-for-large-amounts-of-on-chain-computation/1525/5 "2023-03-13T20:55:10Z")

</div>

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