---
id: BI0121
title: "Wallet domain portfolio"
url: https://carbium.sh/library/blockchainideas/wallet-domain-portfolio
collection: Blockchain ideas
category: Consumer and social
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Wallet domain portfolio

A table of the .sol domains and subdomains a wallet holds. Each name is turned into its registry account locally, 100 accounts are read in one getMultipleAccounts call, and the stored owner is compared with the wallet.

## Who uses it

A profile page, a support desk and a community that hands out subdomains all ask the same thing: which names does this address hold, subdomains included. The registry answers it for any name you can list, and the list itself has to come from your app.

The first group is a wallet or profile app that shows a handle next to an address. The second is a team that gives members names such as `ana.community.sol` under its own domain and wants to see who still holds theirs. The third is a hackathon crew that needs a portfolio screen with a real lookup behind it. All three read the same accounts, and the whole job is read-only, so a demo needs no wallet connection and no signing.

## What it shows

Each name is one line of output, and only the owner column needs a read.

| Column | Where it comes from | Example |
|---|---|---|
| Name | the argument you pass in | `pay.bonfida.sol` |
| Name account | derived locally from the name, no call | an address you can open in an explorer |
| Owner | bytes 32 to 64 of the account data | the wallet, or another address |
| Verdict | owner compared with the wallet | held, other owner, no account or read failed |

A name account starts with a 96-byte header of three addresses: parent, owner and class. The owner sits in the middle, so one slice of the data gives it. A name that was never registered has no account, and the read returns null for it, which the tool prints as no account.

## From a name to its account

Nothing here needs a lookup call. The account address is a program derived address that depends only on the name, so the page computes it in the browser or the server before it reads anything.

1. Take the label and hash `SPL Name Service` followed by the label with SHA-256. A subdomain label gets one zero byte (`\x00`) in front of it before hashing.
2. Derive the address under the name registry program `namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX` with three seeds: the hash, 32 zero bytes for the class, and the parent account.
3. The parent of a top-level name is the .sol root account `58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx`. The parent of a subdomain is its domain's own account, so `pay.bonfida.sol` is derived in two steps, domain first.

A list of 100 names is 100 derivations and then one read.

## The build

The tool is one file on `@solana/kit` and what Node 24 ships. It takes names as arguments and an optional `WALLET` variable. With no `WALLET` it compares against the owner of the first name it finds, which makes a first run work without any setup.

1. Derive the account for every name, as above.
2. Send the accounts to [getMultipleAccounts](https://carbium.sh/docs/rpc) in slices of 100, with base64 data. Each slice is its own try, so one failed call leaves the other slices intact.
3. Cut bytes 32 to 64 from each returned account and decode them as an address.
4. Print one line per name with the owner and a verdict, and name any slice that failed.

`main.ts` (run: `CARBIUM_KEY=<YOUR_KEY> node main.ts bonfida.sol solana.sol sns.sol dex.bonfida.sol`)

```ts
// BI0121 · Wallet domain portfolio
// https://carbium.sh/library/blockchainideas/wallet-domain-portfolio
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressDecoder, getAddressEncoder, getProgramDerivedAddress, type Address } from "@solana/kit";
import { createHash } from "node:crypto";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium API key.");
  process.exit(1);
}
const names = process.argv.slice(2);
if (names.length === 0) {
  console.error("Usage: node main.ts name.sol [more names]. Set WALLET to compare owners.");
  process.exit(1);
}
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

const REGISTRY = address("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX");
const SOL_ROOT = address("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx");
const encode = getAddressEncoder();
const decode = getAddressDecoder();

// foo.sol -> one step under the .sol root; pay.foo.sol -> a second step under foo's account.
async function nameAccount(name: string): Promise<Address> {
  let parent: Address = SOL_ROOT;
  const labels = name.replace(/\.sol$/, "").split(".").reverse();
  for (const [i, label] of labels.entries()) {
    const hashed = createHash("sha256").update("SPL Name Service" + (i === 0 ? "" : "\x00") + label).digest();
    [parent] = await getProgramDerivedAddress({
      programAddress: REGISTRY,
      seeds: [hashed, new Uint8Array(32), encode.encode(parent)],
    });
  }
  return parent;
}

const accounts = await Promise.all(names.map(nameAccount));
const owners = new Map<number, string>();
const failed = new Set<number>();
for (let i = 0; i < accounts.length; i += 100) {
  try {
    const { value } = await rpc.getMultipleAccounts(accounts.slice(i, i + 100), { encoding: "base64" }).send();
    value.forEach((acc, j) => {
      if (acc) owners.set(i + j, decode.decode(Buffer.from(acc.data[0], "base64").subarray(32, 64)));
    });
  } catch (e) {
    console.error(`names ${i} to ${i + 99} failed:`, e instanceof Error ? e.message : e);
    for (let j = i; j < Math.min(i + 100, accounts.length); j++) failed.add(j);
  }
}

const wallet = process.env.WALLET ?? [...owners.values()][0];
console.log(`wallet ${wallet ?? "none"}`);
names.forEach((name, i) => {
  const owner = owners.get(i);
  const verdict = owner ? (owner === wallet ? "held" : "other owner") : failed.has(i) ? "read failed" : "no account";
  console.log(`${name.padEnd(24)} ${accounts[i]} ${owner ?? "-"} ${verdict}`);
});
```

The call leaves commitment out, so @solana/kit fills in confirmed. That suits a portfolio screen, since a domain transfer shows within a second or two. If you want the server's own default, pass `commitment: "finalized"` and read the same accounts.

## What it costs

Account reads are charged in cells per pubkey. getMultipleAccounts costs 10 cells for each, so a slice of 100 names is 1000 cells, and 1001 when the request body passes 4 KiB. A rate class absorbs a burst of 1,024 cells, so one full slice fits and a second one straight behind it can hit the limit on a small plan. Pro takes up to 300 pubkeys in a call, and this code stays at 100 so it runs on every plan.

| Plan | Price per month | Account reads, req/s |
|---|---|---|
| Free | $0 | 0.5 |
| Dev | $20 | 15 |
| Business | $250 | 50 |
| Pro | $500 | 400 |

[Limits are per account](https://carbium.sh/docs/limits), so a profile page and a nightly job on two keys of one account draw on one budget. A portfolio of 25 names is a single call and 250 cells, which any plan serves once per page view. Cache the result per wallet for a few seconds if a page can be reloaded quickly.

## What to add next

- A saved name list per wallet: store each name the app has ever seen for the wallet and re-read the list on every visit. A name that moved away then shows as other owner instead of vanishing.
- A feed of candidates: [getTokenAccountsByOwner](https://carbium.sh/library/howsolana/sol-balances-for-many-accounts) on the wallet lists token accounts with an amount of 1 and zero decimals, which is where an NFT-wrapped domain would show up. Read each mint's metadata name to add it to the list.
- A member check for a community: keep the member names in a table and run this read nightly to flag members whose subdomain changed hands.
- Push updates: when the wallet is active, redo the read after each transaction that mentions it, and compare with the last result.

For resolving one name to one address, the [.sol domain resolver](https://carbium.sh/library/blockchainideas/sol-domain-resolver) is the smaller tool, and this one is its portfolio form.

## Where it ends

- The tool lists no names on its own. Given only a wallet, it cannot tell you what that wallet holds, because the owner field is read from a name you already have. "All" means all names in your list.
- A domain wrapped as an NFT has the wrapping program's account as registry owner while the wallet holds the NFT. The tool prints that as other owner, and the token route above is how to find it.
- Only the owner field is read. Records such as a website, a social handle or the favourite name a wallet picked live in other accounts and are not part of this table.
- A subdomain is checked only under the parent you name. A subdomain issued by the owner of a domain you did not list stays unseen until that name is on the list.
- The owner field is what the registry stores, and it is the only ownership claim the tool makes.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| A name you know is registered shows as no account. | Check the spelling and the parent. A subdomain needs its full dotted form, and a name with a space or a changed letter derives a different address. Print the derived address and open it in an explorer to see it. |
| A slice prints as read failed with a 429. | A full slice costs 1000 cells and the burst is 1,024, so a second slice straight after can be refused. Wait the `retry-after` seconds from the response and send that slice again. |
| A domain the wallet bought shows as other owner. | The domain is probably wrapped as an NFT, so the registry owner is the wrapping program's account. Look for the NFT through the wallet's token accounts instead of its registry owner. |
| Every slice prints as read failed with a 401. | The key was cut short or is unknown. Attach the whole key in `CARBIUM_KEY`; the code sends it in the x-api-key header. |
| The run prints no wallet and every name as no account. | None of the names exist, so there was no owner to fall back to. Pass a name you know is registered, or set `WALLET` and check the list. |

## Questions

### Can I get every domain a wallet owns from just its address?

Not from account reads alone. The registry stores the owner inside each name account, and a read goes by account address, so you need the names first. Keep a list per wallet and grow it from the sources in the section on what to add next.

### Why derive the address on my side instead of asking an API?

The address depends only on the name and two fixed accounts, so deriving it costs no call at all. Only the final read touches the network, and one call covers 100 names.

### Does a subdomain count as owned by the person who holds its domain?

No. A subdomain account has its own owner field, and it can be someone other than the domain's owner. The tool reads each account's own field, which is why it prints one line per name.

### How many names can one call carry?

The code sends 100 per call, which is 1000 cells, and runs on every plan. Pro accepts up to 300 pubkeys in a getMultipleAccounts call, and a version written for Pro could send larger slices.

## Related

- [SOL balances for many accounts](https://carbium.sh/library/howsolana/sol-balances-for-many-accounts) (How to use Solana, HS0016)
- [.sol domain resolver](https://carbium.sh/library/blockchainideas/sol-domain-resolver) (Blockchain ideas, BI0036)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
