Inspecting Accounts & Programs
Use solana account and solana program to read on-chain state, owners, and executable bytecode metadata without writing a client.
Recipe
Quick-reference recipe card - copy-paste ready.
solana account <ACCOUNT_PUBKEY>
solana account <PUBKEY> --output json
solana program show <PROGRAM_ID>
solana program dump <PROGRAM_ID> program.soWhen to reach for this:
- Debugging "account not found" or wrong owner errors.
- Verifying a deployment's program ID and upgrade authority.
- Dumping
.sobytecode for size or hash comparison. - Inspecting rent, data length, and lamport balance quickly.
Working Example
# Inspect the System Program (native program)
solana program show 11111111111111111111111111111111
# Inspect a wallet or data account
solana account "$(solana address)"
# JSON for scripting
solana account "$(solana address)" --output json-compact | jq '.account.lamports, .account.owner'
# Dump program binary from devnet/mainnet
solana program dump TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA spl_token.so
ls -la spl_token.soWhat this demonstrates:
program showlists owner loader, programdata address, authority, and last deploy slot.accountprints lamports, owner, executable flag, and raw data length.program dumpwrites the on-chain ELF to disk for inspection or verification.
Deep Dive
How It Works
- Every account stores lamports, an owner pubkey, data bytes, and flags.
- Programs are accounts marked
executableowned by a loader (BPF Loader v3 for upgradeable programs). solana accountfetches viagetAccountInfoRPC under the hood.- Upgradeable programs split program ID and programdata accounts.
Account Output Fields
| Field | Meaning |
|---|---|
| Lamports | Spendable balance + rent-exempt reserve |
| Owner | Program allowed to write data |
| Executable | true for deployed programs |
| Data Length | Byte size of account data |
| Allocated | Total allocated space (may exceed data length) |
bash Notes
# Show only program metadata without dumping
solana program show <PROGRAM_ID> --programs
# Multiple accounts in one RPC round-trip via client libraries
# CLI inspects one at a time - use @solana/kit for batchesGotchas
- Reading binary as text - account data is not UTF-8 for program-owned accounts. Fix: decode with your IDL, Anchor account structs, or
spl-tokenlayout tools. - Wrong cluster - account exists on devnet but not mainnet. Fix:
solana config getbefore debugging missing accounts. - Assuming program ID equals programdata - upgradeable loader uses two accounts. Fix: read
ProgramData Addressfromprogram show. - Huge account dumps - some accounts are megabytes. Fix: use
--output jsonand parse selectively; avoid piping raw binary to terminal. - Stale upgrade authority display - cached RPC may lag. Fix: query with
finalizedcommitment for authority-sensitive checks.
Alternatives
| Alternative | Use When | Don't Use When |
|---|---|---|
| Solana Explorer / Solscan | Rich UI and token decoding | Scripting or offline workflows |
@solana/kit getAccountInfo | Batch reads in TypeScript apps | One-off terminal inspection |
anchor account | Anchor IDL-typed decode | Native programs without IDL |
spl-token account-info | SPL token account layout | Non-token accounts |
FAQs
What does Owner mean on an account?
The program pubkey permitted to mutate account data. Only the owner program can debit lamports or resize data per the runtime rules.
How do I know if an account is a PDA?
PDAs appear as pubkeys off the Ed25519 curve. The CLI does not label PDAs - derive expected addresses client-side and compare.
Why is Data Length zero on my wallet?
System-owned wallet accounts hold lamports only - no custom data payload.
Can I inspect closed accounts?
No - closed accounts are removed from chain state. Keep transaction signatures to prove historical existence.
What is Allocated vs Data Length?
Allocated is reserved space; data length is bytes currently used. Programs may realloc between them.
How do I decode Anchor account data?
Use anchor account <Type> <PUBKEY> in Anchor projects, or fetch raw bytes and deserialize with your IDL client.
Does program dump include upgrade metadata?
Dump writes executable ELF bytes only. Use program show for authority, slot, and loader metadata.
How do I inspect token mints?
Use spl-token display <MINT> for human-readable mint fields, or solana account for raw bytes.
Can I inspect accounts on localnet?
Yes - point solana config at http://127.0.0.1:8899 and use the same commands.
Why does json output differ from text?
JSON includes base64 data fields suitable for scripts; text output truncates large data for readability.
Related
- Solana CLI Basics - RPC and cluster setup
- Deploying Programs - what
program showvalidates after deploy - spl-token CLI - token-specific account decoding
- Core RPC Methods -
getAccountInfodetails
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.