hardhat_* namespace

Utility methods that mimic Hardhat Network behavior (impersonation, snapshot resets, on demand mining, etc.).
Perfect for Hardhat test suites, Foundry scripts, or any framework that expects the Hardhat JSON-RPC surface.

curl -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"hardhat_impersonateAccount","params":["0x…address…"]}'

Method index

Impersonation

Method✓ / ✗Purpose
hardhat_impersonateAccountStart impersonating an address
hardhat_stopImpersonatingAccountStop impersonation

Mining & automine

Method✓ / ✗Purpose
hardhat_getAutomineAlways returns true (auto‑mine)
hardhat_mineMine N blocks instantly

Chain reset

Method✓ / ✗Purpose
hardhat_resetReset chain (blocknumber only when forked)

State modification

Method✓ / ✗Purpose
hardhat_setBalanceSet account balance
hardhat_setCodeSet account bytecode
hardhat_setNonceSet account nonce
hardhat_setStorageAtSet storage slot

Method reference

Hardhat’s full spec is in the Hardhat Network docs ↗︎.

hardhat_impersonateAccount

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc":"2.0","id":1,
        "method":"hardhat_impersonateAccount",
        "params":["0x…targetAddress…"]
      }'

hardhat_stopImpersonatingAccount

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc":"2.0","id":1,
        "method":"hardhat_stopImpersonatingAccount",
        "params":["0x…targetAddress…"]
      }'

hardhat_getAutomine ▲

Returns true.

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"hardhat_getAutomine","params":[]}'

hardhat_mine

Mine one block or N blocks instantly.

# mine 1 block
curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"hardhat_mine","params":[]}'
# mine 5 blocks
curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":2,"method":"hardhat_mine","params":["0x5"]}'

hardhat_reset ▲

Resets the chain state.
Blocknumber rewinds only work while running in fork mode.

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"hardhat_reset","params":[]}'

hardhat_setBalance

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc":"2.0","id":1,
        "method":"hardhat_setBalance",
        "params":["0x…targetAddress…", "0xDE0B6B3A7640000"]  // 1 ETH
      }'

hardhat_setCode

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc":"2.0","id":1,
        "method":"hardhat_setCode",
        "params":["0x…targetAddress…", "0x60006000…"]  // EVM bytecode
      }'

hardhat_setNonce

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc":"2.0","id":1,
        "method":"hardhat_setNonce",
        "params":["0x…targetAddress…", "0xA"]  // nonce = 10
      }'

hardhat_setStorageAt

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc":"2.0","id":1,
        "method":"hardhat_setStorageAt",
        "params":[
          "0x…targetAddress…",
          "0x0",                    // storage slot
          "0x0000000000000000000000000000000000000000000000000000000000000042"
        ]
      }'

Unimplemented stubs

The following methods are not yet implemented and will return Method not found:

  • hardhat_addCompilationResult
  • hardhat_dropTransaction
  • hardhat_metadata
  • hardhat_setCoinbase
  • hardhat_setLoggingEnabled
  • hardhat_setMinGasPrice
  • hardhat_setNextBlockBaseFeePerGas
  • hardhat_setPrevRandao

See also

  • eth_* — Ethereum compatible base methods
  • zks_* — ZKsync specific extensions
  • anvil_* — node management helpers