0

I was wondering if there is a way to avoid the revert statement in this code example. Or to put it another way, could you write a smart contract that allows arbitrary operations as long as you have a revert all changes at the end of the function.

First, I thought you could call selfdestruct, but that would have an effect after the call and would be undone by revert, right?


 contract Reverter {
 
    function callAndRevert(address externalAddress, bytes  calldata data) public {
    
            // do whatever
            externalAddress.call(data);
            address(this).delegatecall(data);

            // revert
            revert ("Dont care I revert");
                
    }
}

2
  • Hm, nothing i can see would avoid that revert no. Is that a challenge or something, or just a question you're asking?
    – Foxxxey
    Aug 5 at 19:13
  • I saw some protocols (such as uniswap) allowing users to call state modifying functions and then reverting the output. Just wondering about potential security considerations
    – ikijong
    Aug 6 at 20:22

0

Your Answer

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

Browse other questions tagged or ask your own question.