0

I've deployed contract in ropsten test net with this source code:

pragma solidity ^0.4.15;

    contract C{

        function throws(){
            throw;
        }
        function reverts(){
            revert();
        }
        function requires(){
            require(false);
        }
        function asserts(){
            assert(false);
        }
    }

As I expected calling reverts() function should return me all gas. But this doesn't work and all I've paid a lot of ether for this failed transaction (https://ropsten.etherscan.io/tx/0x2084cc38b1695d52448a7cf5c887ca1ea3f82163491cc48c18e8987e6e9defed)

Can someone explain me how it's possible please?

1

revert only refunds unused gas . You can test this by setting a high gas limit 3000000 for example and calling the asserts and reverts methods of your contract, you'll see that asserts consumes all of the gas limit, where as reverts returns unconsumed gas

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.