4

I've been using hardhat node on "automining" during a period of time during the first steps of a project.

When I switched to interval mining for a while and I wanted to come back again to automining I just cannot come back and any submit to the smart contract resolves with:

1 MetaMask - RPC Error: Internal JSON-RPC error. 
{code: -32603, message: 'Internal JSON-RPC error.', data: {…}}
code: -32603
data: {code: -32000, message: 'Received invalid block tag 1698. Latest block number is 138'}
message: "Internal JSON-RPC error."

Block numbers change.

The only way to continue developing is at restarting the blockmining and lowering the blocktime until reach the last block mined. Which is shit.

Is there any way to reset the hardhat node to initials?

Thanks in advance.

The only issues regarding the topic I found are:

StackExchange - received-invalid-block-tag-87-latest-block-number-is-0

and its link to hardhat github issue:

#1906

None of the proposals worked.

2
  • Does switching the network in metamask to mainnet and back to localhost fixes this? It seems like a metamask cache issue or something like that. Commented Oct 21, 2021 at 18:34
  • 1
    Omg, yes 😞 Thanks. I think it was the only $$&%? thing I did not try.
    – Gordo
    Commented Oct 21, 2021 at 18:42

1 Answer 1

4

Thanks to Franco Vitorio's comment

Metamask was caching the mining state between hardhat node sessions and returning a blocktag ahead from the state of the blockchain resulting in an error and not permitting any interaction with the blockchain unless you reach that exact block mined.

Switching networks cleared that metamask state cache.

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.