1

If we make for example a smart contract with a require function that is always false and we execute it tons of times (knowing that we will get our gas back cause of the revert function)will we be able to jam the eth network for free?

1
  • Not for free, since you only get the remaining gas back. Commented Dec 19, 2020 at 20:33

1 Answer 1

0

Not for free, since you only get the remaining gas back.

Here is a short test for illustrating that:

Solidity Contract:

pragma solidity 0.6.12;

contract MyContract {
    function test() public {
        revert();
    }
}

Truffle 5.x Test:

contract("test", function (accounts) {
    it("test", async function () {
        const myContract = await artifacts.require("MyContract").new();
        const balanceBefore = web3.utils.toBN(await web3.eth.getBalance(accounts[0]));

        try {
            await myContract.test();
        }
        catch (error) {
        }

        const balanceAfter = web3.utils.toBN(await web3.eth.getBalance(accounts[0]));
        console.log(web3.utils.fromWei(balanceBefore.sub(balanceAfter)).toString());
    });
});

The printout indicates that the sender account has spent 0.00042366 ether.

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.