1

I wonder whether it is possible to roll multiple transactions into one transaction and post it on the chain, similar behavior to L2 chains.

I will have a smart contract where there might be a high traffic on it, and the transactions will be submitted from my own wallet. So I was wondering, maybe I can do something like collect all the signed transactions in a database, and then roll them into one transaction (using merkle trees etc.).

The transaction can be call to any of the non-view functions on the smart contract.

Can this be achieved? If yes how?

2 Answers 2

1

https://furucombo.app/ and https://defisaver.com/ Both have transaction builders to use the Ethereum money legos and craft combined transactions from a web dapp!

2
  • Thank you for the answer! These apps looks like apps to manage the portfolio on DeFi applications. I am not sure I can use the transaction builder in here to submit the transactions from my own smart contract. Even if it is possible and I missed it, I need to do it in a programmatical way rather than doing it with a UI. Sep 16, 2022 at 21:19
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 16, 2022 at 22:58
1

For instance, they use optimism rollups or Zksnarks; where multiple transactions are rolled up and publish in block in the form of snapshots.

However, if you want to roll up multiple transactions into single transaction all you have to do it is write another function that calls multiple functions.

Say for example,

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;

contract A {

    uint public s_sum;
    uint public s_mul;

    function sum(uint a, uint b) public{
        s_sum =  a + b;
    }

    function mul(uint a, uint b) public {
        s_mul =  a * b;
    }

    function jointExec(uint a, uint b) public {
        sum(a,b);
        mul(a,b);
    }
}

If you call individually, sum takes around 28,000 gas and mul takes 28,000 gas.

However, if you use joinExec function, the transaction costs around 38,000. So you are saving 20,000 gas.

Just not that, you can also create another smart contract which is already deployed to use jointExecution just I showed.

Tell me if that is what you are looking for.

1
  • Thank you very much for your answer. Combining multiple functions into single function is not applicable in my case, because what I'm looking for (which might not be possible to do) is being able to joint any kind of and any number of transactions, sometimes even lets say 10 of sum functions. But I would like to hear more on the rollup contracts. Would it feasible and efficient for me to build my own rollup contract logic, and submit rolled transactions to that contract? And would that cause any possible problems considering my contract is NFTish contract? Sep 17, 2022 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.