0

I want to know if a reverted transaction is considered as mined one ?

this is mean nonce should be incremented

  • Why don't you check it and find out? – goodvibration Oct 29 '19 at 9:53
3

A transaction can't revert unless it's mined. This is because miners are the ones who actually execute the transaction. Furthermore a reverted transaction is a valid transaction so it's a regular transaction which just didn't succeed and was rolled back.

So yes you have to increase your nonce.

| improve this answer | |
2

A simple Truffle test to prove that it does:

Contract File:

pragma solidity 0.4.25; 

contract MyContract {
    uint x;
    function func(uint _x) public {
        require(x != _x);
        x = _x;
    }
}

Test File:

contract("test", function(accounts) {
    it("test", async function() {
        await printNonce(accounts[0]);
        const myContract = await artifacts.require("MyContract").new({from: accounts[0]});
        await printNonce(accounts[0]);
        await myContract.func(1, {from: accounts[0]});
        try {
            await printNonce(accounts[0]);
            await myContract.func(1, {from: accounts[0]});
            throw null;
        }
        catch (error) {
            assert(error && error.message.startsWith("VM Exception"));
        }
        await printNonce(accounts[0]);
        await myContract.func(2, {from: accounts[0]});
        await printNonce(accounts[0]);
    });
});

async function printNonce(account) {
    const nonce = await web3.eth.getTransactionCount(account);
    console.log(nonce);
}

Printout:

0
1
2
3
4
| improve this answer | |

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.