Skip to main content

Usage

dokrypt fork [network] [flags]

Arguments

ArgumentRequiredDescription
networkNoNetwork name or custom RPC URL

Flags

FlagTypeDefaultDescription
--urlstringCustom RPC URL to fork from
--blockuint640Fork at a specific block number (0 = latest)
--chainstringTarget chain name (for multi-chain setups)
--accountsint10Number of accounts to fund

Description

Resets the local chain to a fork of a live blockchain network. After forking, your local environment has the complete state of the target network at the specified block — you can interact with all deployed contracts (Uniswap, Aave, etc.) as if you were on mainnet.

How It Works

  1. Resolves the network name to an RPC URL (or uses the custom --url)
  2. Calls anvil_reset (or hardhat_reset) with forking parameters
  3. Waits up to 120 seconds for the fork to complete
  4. Fetches the new chain ID and block number
  5. Funds the specified number of accounts with 10,000 ETH each

Supported Networks

NetworkAliasesChain IDRPC URL
Ethereummainnet, ethereum1https://eth.llamarpc.com
Sepoliasepolia11155111https://rpc.sepolia.org
Goerligoerli5https://rpc.ankr.com/eth_goerli
Polygonpolygon137https://polygon-rpc.com
Arbitrumarbitrum42161https://arb1.arbitrum.io/rpc
Optimismoptimism10https://mainnet.optimism.io
Basebase8453https://mainnet.base.org
BSCbsc56https://bsc-dataseed.binance.org
Avalancheavalanche43114https://api.avax.network/ext/bc/C/rpc

Examples

Fork Ethereum mainnet (latest block)

dokrypt fork mainnet

Fork at a specific block

dokrypt fork mainnet --block 18500000

Fork Polygon

dokrypt fork polygon

Fork with a custom RPC URL

dokrypt fork --url https://your-alchemy-url.com/v2/API_KEY

Fork with more funded accounts

dokrypt fork mainnet --accounts 20

Fork a specific chain in a multi-chain setup

dokrypt fork arbitrum --chain l2

Use Cases

Test against real DeFi protocols

dokrypt fork mainnet --block 18500000

# Now you can interact with Uniswap, Aave, Compound, etc.
# at the exact state of block 18,500,000

Reproduce a mainnet bug

# Fork at the block just before the bug
dokrypt fork mainnet --block 17999999

# Impersonate the affected account
dokrypt accounts impersonate 0xAffectedAddress...

# Replay the transaction

Test token integrations

dokrypt fork mainnet

# Fund your test account with real USDC
dokrypt chain set-balance 0xYourAddress... 1000

# Impersonate a whale to get tokens
dokrypt accounts impersonate 0xUSDCWhale...