1

Hello ethereum community. I'm experimenting with low level calls and i want to revert the transaction made by low level call, if i didn't get the desired result. Is it possible?

(bool success, ) = _contractOne.call{value: 10, gas: 100000}(payload);
        require(success);

let's say this is my call to swap on uniswap and i get lower output token. how to revert the transaction to initial state?

1 Answer 1

1

You can use this code to revert function if success be false.

(bool success, ) = _contractOne.call{value: 10, gas: 100000}(payload);

if (!success) {
    // Revert the transaction if the low-level call fails
    revert("Low-level call failed");
}

// Continue with your code if the low-level call was successful
1
  • 1
    👍 thanks bro.. Oct 7, 2023 at 10:38

Your Answer

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

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