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_impersonateAccount | ✓ | Start impersonating an address |
hardhat_stopImpersonatingAccount | ✓ | Stop impersonation |
Mining & automine
Method | ✓ / ✗ | Purpose |
---|---|---|
hardhat_getAutomine | ▲ | Always returns true (auto‑mine) |
hardhat_mine | ✓ | Mine N blocks instantly |
Chain reset
Method | ✓ / ✗ | Purpose |
---|---|---|
hardhat_reset | ▲ | Reset chain (blocknumber only when forked) |
State modification
Method | ✓ / ✗ | Purpose |
---|---|---|
hardhat_setBalance | ✓ | Set account balance |
hardhat_setCode | ✓ | Set account bytecode |
hardhat_setNonce | ✓ | Set account nonce |
hardhat_setStorageAt | ✓ | Set 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