0

Say I want to make a transaction that calls foo() and the calls bar() afterwards. I could make a contract that calls them both in sequence, but that's kind of a pain. Is there a way to just call both without prompting the user for multiple signatures? And if so will foo() revert if bar() reverts and vice versa?

0

There is no way to do this without using a contract.

In general, due to Ethereum's "no features" design principle, anything more complex than a simple transaction will require a smart contract. In this case the contract would be very small, and you can simply deploy it once and reuse it.

0

The user signs one transaction. It can involve many contracts and functions, according to design. It will also be atomic - completing or reverting entirely.

There is no way to have the user sign two such transactions or receive the same assurances about two separately signed transactions.

Hope it helps.

0

You may call all in one transaction by deploying contract looking like this:

contract Target {
    function foo () public;
    function bar () public;
}

contract Batch {
  constructor (Target target) public {
    target.foo ();
    target.bar ();
    selfdestruct (msg.sender);
  }
}

This will revert foo() in case bar() will fail.

Though, this will call foo() and bar() from temporary smart contract address rather than from your real address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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