Usage
dokrypt snapshot <subcommand> [flags]
Subcommands
| Subcommand | Description |
|---|
save | Save current chain state |
restore | Restore to a saved snapshot |
list | List all snapshots |
delete | Delete a snapshot |
export | Export snapshot to a file |
import | Import snapshot from a file |
diff | Compare two snapshots |
save
Save the current chain state as a named snapshot.
dokrypt snapshot save <name> [flags]
Arguments
| Argument | Required | Description |
|---|
name | Yes | Snapshot name (used for restore/delete) |
Flags
| Flag | Type | Default | Description |
|---|
--description | string | — | Human-readable description |
--tags | string[] | — | Tags for categorization (repeatable) |
How It Works
- Calls
evm_snapshot via JSON-RPC on the running chain
- Records the current block number and chain ID
- Saves metadata to
~/.dokrypt/snapshots/<project>/<name>.json
Examples
# Simple save
dokrypt snapshot save initial-state
# With description
dokrypt snapshot save before-deploy --description "Clean state before contract deployment"
# With tags
dokrypt snapshot save checkpoint --tags critical --tags v1.0
restore
Restore chain state to a previously saved snapshot.
dokrypt snapshot restore <name>
Arguments
| Argument | Required | Description |
|---|
name | Yes | Snapshot name to restore |
How It Works
- Loads the snapshot metadata
- Calls
evm_revert with the snapshot ID
- Takes a new snapshot at the same point (EVM snapshots are consumed on revert)
- Returns the current block number
Examples
dokrypt snapshot restore initial-state
EVM snapshots are single-use — once reverted, the snapshot ID is consumed. Dokrypt automatically takes a new snapshot after restoring so you can restore again later.
list
List all snapshots for the current project.
Output
Name Block Created Description
initial-state 0 2025-01-15 10:30:00 Fresh state
before-deploy 42 2025-01-15 10:35:00 Before contract deployment
after-tests 108 2025-01-15 10:42:00 After running test suite
Snapshots are sorted by creation time (newest first).
delete
Delete a saved snapshot.
dokrypt snapshot delete <name>
Examples
dokrypt snapshot delete old-checkpoint
export
Export a snapshot to a JSON file for sharing or backup.
dokrypt snapshot export <name> <path>
Arguments
| Argument | Required | Description |
|---|
name | Yes | Snapshot name |
path | Yes | Output file path |
How It Works
- Loads snapshot metadata
- Calls
anvil_dumpState to export the full chain state
- Writes a JSON file containing both metadata and state data
Examples
dokrypt snapshot export initial-state ./backups/state.json
The exported file contains:
{
"metadata": {
"name": "initial-state",
"block_number": 0,
"chain_id": 31337,
"created_at": "2025-01-15T10:30:00Z"
},
"state": { ... }
}
anvil_dumpState is Anvil-specific. Export may not work with Hardhat or Geth chains.
import
Import a snapshot from a JSON file.
dokrypt snapshot import <path>
Arguments
| Argument | Required | Description |
|---|
path | Yes | Path to the snapshot JSON file |
How It Works
- Reads and parses the JSON file
- Loads the chain state via
anvil_loadState
- Saves the metadata to the local snapshot registry
Examples
dokrypt snapshot import ./backups/state.json
diff
Show differences between two snapshots.
dokrypt snapshot diff <snap1> <snap2>
Arguments
| Argument | Required | Description |
|---|
snap1 | Yes | First snapshot name |
snap2 | Yes | Second snapshot name |
Output
Shows the block number delta and time difference between snapshots.
Examples
dokrypt snapshot diff before-deploy after-deploy
Comparing: before-deploy vs after-deploy
Block delta: +66 blocks (42 → 108)
Time delta: 7m12s