Given access to Solana validator node and solana command, how to export a list of all account addresses with positive balance (at the latest block)? Preferably in CSV format.

1 Answer 1


This assumes the solana CLI utils are available

  1. Create a new directory named ledger
  2. Download genesis and a snapshot (full and incremental if applicable) from the target cluster and move them inside. Use something like [1] to list available source validators and use a single source for all files
  3. Use ledger tool to dump all accounts to JSON and consume however you please
solana-ledger-tool --ledger ./ledger accounts --output json

[1] (requires jq)

!/usr/bin/env bash

cluster=devnet # one of `localhost`, `devnet`, `testnet`, `mainnet-beta` or custom RPC URL

canonical_snapshot_url() {
  local -r relative_url="${1:?'missing required arg 1: `relative_url`'}"
  url="$(wget -nv --connect-timeout 3 --tries 1 --method HEAD "$relative_url" 2>&1)"
  local -r rc=$?
  if [[ $rc -eq 0 ]]; then
    cut -d' ' -f4 <<<"$url"
  return $rc
while read RPCHOST; do
    full_url="$(canonical_snapshot_url http://${RPCHOST}/snapshot.tar.bz2)"
    if [[ 0 = $? ]]; then
      gen_url="$(canonical_snapshot_url http://${RPCHOST}/genesis.tar.bz2)"
      inc_url="$(canonical_snapshot_url http://${RPCHOST}/incremental-snapshot.tar.bz2)"
      if [[ 0 = $? ]]; then
      echo -e "$out\n --"
  ) &
done < <(solana -u "$cluster" gossip --output json | jq -r '.[].rpcHost | select (. != null)')

wait ${pids[*]}
  • what is genesis?
    – kafinsalim
    Commented Aug 9, 2022 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.