Override State
Set code, nonce, or a storage slot at any address on your Stagenet from the command line.
Targets your active stagenet — see Target a Stagenet. Backed by the state RPC methods.
state set-code
Replace the bytecode at an address. Pass "0x" to wipe.
contract.dev state set-code 0xContract... 0x6042...
contract.dev state set-code 0xContract... 0x # empty| Argument | Description |
|---|---|
<address> | A 0x-prefixed Ethereum address |
<bytecode> | The bytecode as 0x-prefixed hex |
state set-nonce
Set the nonce on an account.
contract.dev state set-nonce 0x1111... 42
contract.dev state set-nonce 0x1111... 0x10 # = 16| Argument | Description |
|---|---|
<address> | A 0x-prefixed Ethereum address |
<nonce> | Non-negative integer (decimal or 0x-hex) |
state set-storage
Write a 32-byte value into a specific storage slot.
contract.dev state set-storage 0xContract... \
--slot 0 \
--value 0x000000000000000000000000000000000000000000000000000000000000002a| Argument | Description |
|---|---|
<address> | The contract address |
--slot <slot> | Storage slot key — a decimal slot number (5) or 0x hex (≤32 bytes, left-padded). 10 is slot ten, not 0x10. |
--value <0x..> | Value to write — exactly 32 bytes (0x + 64 hex chars). Short hex like 0x2a is rejected; pad explicitly. |
Slot keys are uint256, so decimal and short hex are unambiguous. Values are not (uint-style vs bytes-style padding) — pad them with "0x" + n.toString(16).padStart(64, "0") (or viem’s pad(toHex(n))).
Notes
- These commands match the semantics of Hardhat’s
hardhat_setStorageAt, Anvil’sanvil_setStorageAt, and Foundry’svm.store. - For ERC20 balances specifically, prefer
erc20-balance— it handles the standardbalanceOfslot for you.
Last updated on