Build an account explorer
Build your own mini Solscan from scratch and learn to decode the five core fields that define every Solana account.
Build an account explorer
The Scenario
You have spent the past few days poking around Solana accounts, reading their data, and inspecting what lives on-chain. You know that every address on Solana points to an account, and that every account has a balance, an owner, a data field, and an executable flag.
But right now, finding all of that information means running one-off scripts and staring at raw terminal output.
Today, you are going to change that. You will build a simple command-line account explorer: give it any Solana address and it will pull together everything you need to know about that account in one clean, readable summary.
Think of it as your own mini Solscan, running right in your terminal.
The Challenge
What You’ll Need
- A code editor (VS Code, Cursor, or similar)
- Node.js (v18 or later) installed
- A terminal
- A Solana RPC endpoint (the public devnet endpoint
https://api.devnet.solana.comworks fine for this)
Steps
Every great tool starts with a solid foundation. In Solana development, that means setting up your environment to handle modern JavaScript and the official @solana/kit.
First, initialize your project in the terminal:
- Set up the project: Create a new directory and initialize it:
mkdir solana-account-explorer && cd solana-account-explorer
npm init -y && npm install @solana/kit
We need to tell Node.js that we’re using ES Modules so we can use import statements. Open your package.json and add “type”: “module”. You can see how the finished metadata should look in Step 1 in this Gist.
- Connecting to the Cluster: Create a file named explorer.mjs. Our first task is to establish a connection to the Solana network. We’ll use the public devnet RPC endpoint for this.
We import the necessary functions from the kit and point our script at the devnet “post office.” Check Step 2 in the Gist to see the setup.
- Handling User Input: An explorer is useless if it can’t take an address. We need to grab the address from the command line when the script is run (e.g., node explorer.mjs [ADDRESS]).
We use process.argv to “listen” to what the user types. We also need to add a small guard-rail: if the user forgets the address, we should show a helpful error message. You’ll find this logic at Step 3 of the Gist.
- The “Heads-Up” Display: Balance & Info: Now for the heavy lifting. We need to ask the Solana network two questions: “How much SOL does this account have?” and “What else do you know about it?”
We use getBalance and getAccountInfo. Remember, Solana stores balances in lamports, so we’ll divide by one billion to show a human-friendly SOL value. We also pull the owner and data fields, which tell us if this is a person’s wallet or a smart contract. Follow the data-fetching pattern in Steps 4 & 5 of the Gist.
- Making it Readable: Raw Solana addresses are just strings of random characters. To make our explorer feel “pro,” we should map famous program addresses (like the System Program or Token Program) to friendly names.
We’ll create a simple “translation” map. If the owner is 1111…, our script will say “System Program.” Check out the KNOWN_PROGRAMS list in Step 6.
- The Grand Reveal: Finally, we print it all to the screen. We want a clean layout that shows the address, the owner, and a peek at the account data.
Since account data can be massive, we include logic to “truncate” it—showing just enough to see what’s happening without crashing your terminal. The final formatting logic is at Step 7.
Run It
Try your explorer with a well-known program address first:
node explorer.mjs TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Then try it with your own devnet wallet address. If you generated a keypair in earlier days, use that address. You should see your SOL balance, the System Program as the owner, and zero bytes of data (because wallet accounts do not store custom data).
Try a few more addresses to see how the output changes. Program accounts will show executable: true. Token accounts will show the Token Program as the owner and will have data attached.
What Just Happened
You built a tool that talks directly to a Solana node over JSON-RPC and translates raw account data into something a human can read. This is exactly what block explorers like Solana Explorer, Solscan, and SolanaFM do under the hood: they call the same RPC methods you just used, then wrap the results in a web interface.
The five fields you displayed (balance, owner, data, executable, rent epoch) are the core of Solana’s account model. Every single account on the network, whether it holds SOL, stores token balances, or runs program logic, is described by these same fields. The difference between a wallet and a program comes down to one boolean flag (executable) and which program address sits in the owner field.
By mapping owner addresses to friendly names, you also started building intuition for how Solana’s ownership model works. The System Program owns wallets. The Token Program owns token accounts. When you build your own programs later in this journey, your program’s address will show up as the owner of the accounts it creates.
Resources
- Solana Accounts Documentation
- getAccountInfo RPC Method Reference
- @solana/kit on npm
- Solana RPC HTTP Methods
Submission
Take a screenshot of your terminal showing the explorer output for at least two different addresses (one wallet, one program). Then, upload it here!