Cloning Mainnet Accounts
Seed solana-test-validator with real mainnet account data so local tests exercise production program layouts and oracle state.
Search across all documentation pages
Seed solana-test-validator with real mainnet account data so local tests exercise production program layouts and oracle state.
Quick-reference recipe card - copy-paste ready.
solana-test-validator --reset \
--url mainnet-beta \
--clone <ACCOUNT_PUBKEY> \
--clone <PROGRAM_ID>When to reach for this:
# Example: clone SPL Token program and a USDC mint (verify current pubkeys in docs)
TOKEN_PROGRAM=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
USDC_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
solana-test-validator --reset \
--url mainnet-beta \
--clone "$TOKEN_PROGRAM" \
--clone "$USDC_MINT"
solana config set --url http://127.0.0.1:8899
solana account "$USDC_MINT"What this demonstrates:
--url RPC.--clone pubkey's lamports, owner, data, and executable flag.| Account type | Clone? | Notes |
|---|---|---|
| Program IDs | Often yes | Required for CPI |
| Pool/oracle state | Yes | Captures realistic reserves |
| User wallets | Rare | Use local keypairs instead |
| Sysvars | Auto | Clock, rent included by default |
# Clone many accounts from a file (one pubkey per line)
solana-test-validator --reset --url mainnet-beta \
$(awk '{print "--clone "$1}' accounts.txt)--url.| Alternative | Use When | Don't Use When |
|---|---|---|
| Surfpool 0.12.0 | Continuous mainnet fork | Simple program-only tests |
| Hand-built fixtures | Tiny isolated unit tests | Complex DeFi integrations |
| devnet mirrors | Shared team staging | Mainnet-specific program versions |
| LiteSVM account injection | Fast Rust unit tests | Full RPC client paths |
Yes for executable accounts - the ELF is stored like a deploy.
Yes if the PDA account exists on mainnet at fetch time - derive address and verify with solana account.
Inspect mainnet transactions in an explorer - copy all accounts your instruction touches.
Only if the program is native builtin or you clone/deploy it locally.
No - read-only RPC fetch; you pay local rent only if transactions resize accounts.
Yes - --url devnet for devnet-published programs.
Very large accounts slow startup - prefer Surfpool for heavy fork scenarios.
Yes - token account lamports and data copy exactly at fetch snapshot.
Read validator startup logs for RPC errors; verify pubkey exists on source cluster.
Cache ledger directories or use minimal fixture sets to keep CI fast and reliable.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026