---
id: HS0023
title: "Wrapped SOL account reader"
url: https://carbium.sh/library/howsolana/wrapped-sol-account-reader
collection: How to use Solana
category: SPL tokens
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Wrapped SOL account reader

The wrapped SOL mint address, what a wSOL token account holds, and one read-only TypeScript file that lists a wallet's wSOL accounts and checks each account's lamports against its rent reserve and token amount.

## The wSOL address

The wrapped SOL mint address is `So11111111111111111111111111111111111111112`. It is the wrapped SOL mint of the classic token program, and it is one address for all of mainnet. Token-2022 has its own native mint, listed in the table.

| Field | Value |
|---|---|
| Mint address | `So11111111111111111111111111111111111111112` |
| Owner program | The classic token program, `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` |
| Token-2022 native mint | `9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP`, a separate mint for SOL held under the Token-2022 program |
| Decimals | 9 |
| Unit | One token unit is one lamport, so 1 SOL is 1,000,000,000 units |

Wrapped SOL is SOL held inside an SPL token account. Code written for tokens can then move it with the same instructions it uses for USDC. No reserve sits behind it: the lamports live in the token account itself. Once a `syncNative` instruction has counted any lamports sent in directly, the token program keeps the account's `amount` equal to its lamports minus the rent-exempt reserve stored when the account was opened.

## What a wSOL account holds

A wSOL token account looks like any other token account, with a few fields that matter more than usual.

- `lamports` on the account itself is the real SOL balance, rent reserve included.
- `isNative` is `true`. It marks the account as holding SOL.
- `rentExemptReserve` is the part of those lamports that keeps the account alive. It is not spendable as wSOL.
- `tokenAmount.amount` is the wrapped balance in lamports, as a string.
- `owner` is the wallet or program that controls the account.

The balance you can unwrap is `amount`, and the number that should match it is `lamports` minus `rentExemptReserve`. Unwrapping means closing the account. The token program sends every lamport in it, reserve included, to the destination you name, and the account disappears.

A wallet can own more than one wSOL account. The associated token account is the usual one, but programs often open temporary ones for a single swap. Listing by owner finds all of them, while deriving one address finds only the associated account.

## The code

Install `@solana/kit` at 8.6.0, export `CARBIUM_KEY`, optionally set `CARBIUM_RPC_URL` (every call goes there, and it defaults to `https://services.carbium.sh`) and run the file with Node 24. Give it a wallet address and it lists that wallet's wSOL accounts. Give it nothing and it reads the newest signatures that touched the mint, takes the first successful transaction that left a wSOL balance behind, and reads that token account.

`main.ts` (run: `node main.ts [wallet-address]`)

```ts
// HS0023 · Wrapped SOL account reader
// https://carbium.sh/library/howsolana/wrapped-sol-account-reader
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";

const WSOL = address("So11111111111111111111111111111111111111112");
const key = process.env.CARBIUM_KEY ?? "";
if (key === "") {
  console.error("CARBIUM_KEY is not set: export your Carbium API key first.");
  process.exit(1);
}
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);
const confirmed = { commitment: "confirmed" } as const;

type Info = {
  owner: string;
  isNative: boolean;
  rentExemptReserve?: { amount: string };
  tokenAmount: { amount: string; uiAmountString: string };
};
type Parsed = { lamports: bigint; data: { parsed?: { info?: Info } } };

function report(pubkey: string, acct: Parsed): void {
  const info = acct.data.parsed?.info;
  if (!info) {
    console.log(`${pubkey}: not a parsed token account`);
    return;
  }
  const reserve = BigInt(info.rentExemptReserve?.amount ?? 0);
  const amount = BigInt(info.tokenAmount.amount);
  console.log(`${pubkey} owner=${info.owner} isNative=${info.isNative}`);
  console.log(`  lamports=${acct.lamports} reserve=${reserve} amount=${amount} (${info.tokenAmount.uiAmountString} SOL)`);
  console.log(`  lamports - reserve == amount: ${acct.lamports - reserve === amount}`);
}

// No wallet given: scan the mint's newest signatures for a wSOL balance.
async function findAccount(): Promise<string | undefined> {
  const sigs = await rpc.getSignaturesForAddress(WSOL, { ...confirmed, limit: 10 }).send();
  for (const { signature, err } of sigs) {
    if (err) continue;
    const tx = await rpc
      .getTransaction(signature, { ...confirmed, encoding: "jsonParsed", maxSupportedTransactionVersion: 1 })
      .send();
    const hit = tx?.meta?.postTokenBalances?.find((b) => b.mint === WSOL);
    if (tx && hit) return tx.transaction.message.accountKeys[hit.accountIndex].pubkey;
  }
}

async function readMint(): Promise<void> {
  const { value } = await rpc.getAccountInfo(WSOL, { ...confirmed, encoding: "jsonParsed" }).send();
  const parsed = value?.data as unknown as { parsed?: { info?: { decimals: number } } } | undefined;
  console.log(`mint ${WSOL} owner=${value?.owner} decimals=${parsed?.parsed?.info?.decimals}`);
}

async function readAccounts(wallet: string | undefined): Promise<void> {
  if (wallet) {
    const res = await rpc
      .getTokenAccountsByOwner(address(wallet), { mint: WSOL }, { ...confirmed, encoding: "jsonParsed" })
      .send();
    if (!res.value.length) console.log(`${wallet} holds no wSOL token account`);
    for (const item of res.value) report(item.pubkey, item.account as unknown as Parsed);
    return;
  }
  const found = await findAccount();
  if (!found) {
    console.log("no wSOL account found in the newest signatures");
    return;
  }
  const { value } = await rpc.getAccountInfo(address(found), { ...confirmed, encoding: "jsonParsed" }).send();
  if (value) report(found, value as unknown as Parsed);
  else console.log(`${found} was closed after that transaction; run again`);
}

for (const out of await Promise.allSettled([readMint(), readAccounts(process.argv[2])])) {
  if (out.status === "rejected") console.error("failed:", out.reason);
}
```

The file does three reads. `getAccountInfo` on the mint in `jsonParsed` encoding confirms the owner program and the 9 decimals. `getTokenAccountsByOwner` with a `mint` filter lists the wallet's wSOL accounts in one call. In the no-argument path, `getSignaturesForAddress` and `getTransaction` find an account to look at. Each call passes `commitment: "confirmed"`, and `getTransaction` passes `maxSupportedTransactionVersion: 1` so a v1 transaction does not fail the lookup.

The mint read and the account read run under `Promise.allSettled`, so one failing call is printed and the other still reports.

## Reading the output

For each account the file prints the owner, the account's lamports, the reserve, the token amount and the `uiAmountString`, which is the amount in SOL as exact decimal text. The last line compares `lamports - reserve` with `amount` and prints `true` when they match.

`false` means lamports arrived by a plain system transfer and no `syncNative` has run, so the account holds more SOL than its token amount says. Programs that read `amount` will not see the extra lamports until someone syncs the account.

> The wallet's `getBalance` result does not include wSOL. A wallet with 2 SOL in a wrapped account and 0.1 SOL loose reports 0.1 SOL there, and the 2 SOL shows only in its token accounts.

## On Carbium

`getAccountInfo` is an account read and costs 10 cells. `getSignaturesForAddress` and `getTransaction` cost [50 cells each](https://carbium.sh/docs#rpc), so the no-argument path spends most of its cells on the transaction lookups. The file stops at the first transaction that has a wSOL balance, which is usually the first one, because the mint sits in a large share of swaps.

`getSignaturesForAddress` on Carbium reads from an address index that keeps up to 30 days. Its pages can reach below the validator's ledger floor, so `getTransaction` may answer `null` for an older signature the list still shows. The file skips a `null` and tries the next signature. Prove your own variant on the newest signatures.

## Where it ends

The file reads. It never wraps or unwraps anything, because both need a signed transaction and the file holds no keypair. Wrapping creates the associated account first when it does not exist yet (the idempotent create instruction), then makes a system transfer into it, then runs `syncNative`. Unwrapping is a `closeAccount` instruction.

The no-argument path picks an account from a recent transaction, and the account may be gone by the time the file reads it. Swap programs open a wSOL account and close it in the same transaction, and a short-lived one can close in the next. The file prints a plain message when the read returns `null`, and a second run picks a different one.

`getTokenAccountsByOwner` returns every wSOL account the owner has. For a wallet that is a handful. For a pool authority or a program with thousands of vaults, the reply is large, and the file prints every account it gets back. Point it at wallets, and use a program's own vault addresses for programs.

The 30-day address index limits the finder. It reads the newest signatures only, and it cannot tell you when an account was created if that was more than 30 days ago.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The token amount is lower than lamports minus the reserve, and the last line prints `false`. | Lamports were sent straight to the account. Add a `syncNative` instruction for that account to the transaction that funds it, or send a `syncNative` on its own to catch the account up. |
| `getTransaction` answers -32015 for a signature. | Pass `maxSupportedTransactionVersion: 1` with an encoding. Without it, a v1 transaction is refused. |
| `getTokenAccountsByOwner` returns an empty list for a wallet that swapped through wSOL. | The swap closed its temporary wSOL account in the same transaction. A wallet has a wSOL token account only until it is closed, so an empty list is a valid answer. |
| `getTransaction` answers `null` for a signature that `getSignaturesForAddress` just listed. | The transaction is older than the validator's ledger, and the address index still lists it. Skip it, as the file does, and take a newer signature. |

## Questions

### What is the wSOL mint address?

`So11111111111111111111111111111111111111112`. It is a mint owned by the classic token program, with 9 decimals, and it is one address for all of mainnet.

### Is wSOL the same as SOL?

One wSOL unit is one lamport, and you can turn it back into SOL by closing its token account. The two live in different places, though: SOL sits in a wallet's own balance, and wSOL sits in a token account that counts as a separate asset to token programs.

### Do I need to wrap SOL to read a wSOL account?

No. The file only reads. Wrapping needs a signed transaction, and nothing here signs or sends.

### How do I get the SOL back out of a wSOL account?

Close the account with the token program's `closeAccount` instruction and name the wallet that should receive the lamports. The reserve comes back with the balance.

## Related

- [SPL token balance](https://carbium.sh/library/howsolana/spl-token-balance) (How to use Solana, HS0001)
- [Wallet token holdings](https://carbium.sh/library/usecase/wallet-token-holdings) (Use cases, UC0005)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
