Override State
Set code, nonce, or a storage slot at any address on your Stagenet from the command line.
This CLI wraps the state SDK methods. Use them when you want the same actions driven from a script.
Usage
With a contract.dev.js at your project root (see Setup):
contract.dev state <subcommand>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 |
Sample output:
Set code at 0xContract... (3 bytes)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) |
Sample output:
Set nonce for 0x1111111111111111111111111111111111111111 = 42state set-storage
Write a 32-byte value into a specific storage slot.
contract.dev state set-storage 0xContract... \
--slot 0x0000000000000000000000000000000000000000000000000000000000000000 \
--value 0x000000000000000000000000000000000000000000000000000000000000002a| Argument | Description |
|---|---|
<address> | The contract address |
--slot <0x..> | Storage slot key — exactly 32 bytes (0x + 64 hex chars). Short hex like 0x0 is rejected; pad explicitly. |
--value <0x..> | Value to write — exactly 32 bytes. |
Pad short hex with "0x" + n.toString(16).padStart(64, "0") (or viem’s pad(toHex(n))).
Sample output:
Set storage at 0xContract...
slot: 0x0000000000000000000000000000000000000000000000000000000000000000
value: 0x000000000000000000000000000000000000000000000000000000000000002aNotes
- 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