Overview
Chain utilities give you full control over your local blockchain’s state and behavior. These are essential for testing time-dependent logic, simulating edge cases, and debugging transactions.
Mining Blocks
Force mine one or more blocks:
Mining is useful for:
- Advancing the chain after sending transactions
- Simulating block production in manual mining mode
- Testing block-dependent logic
Time Travel
Advance the blockchain’s clock without waiting:
After advancing time, Dokrypt automatically mines a block to apply the timestamp change.
Common Use Cases
Combine time-travel with snapshots for efficient testing: snapshot before time-travel, test, then restore.
Setting Balances
Set any account’s ETH balance:
The amount is in ETH (not wei). Supports decimals:
Impersonating Accounts
Impersonate any address — transactions from this address will succeed without the private key:
This is critical for:
- Testing admin-only functions on forked contracts
- Simulating whale behavior
- Interacting with governance contracts as specific voters
Example: Transfer tokens from a whale
Setting Gas Price
Control the base gas price for testing gas-sensitive logic:
Resetting the Chain
Reset to genesis state or a new fork:
Display current chain state:
Output:
Multi-Chain Usage
For projects with multiple chains, use --chain to target a specific one:
RPC Methods Used
Under the hood, Dokrypt uses these JSON-RPC methods: