0%

Solana fundamentals in plain words

Lamports, accounts, fees, transactions and stablecoins, with small scripts you can run on devnet

This is my practical tour of how Solana stores money, keeps state, charges fees, runs transactions in parallel, and supports custom tokens and stablecoins. Every section has a short script you can run on devnet, so nothing costs real money.

Setup takes a minute (TypeScript, @solana/web3.js v1 and @solana/spl-token):

mkdir solana-basics && cd solana-basics
npm init -y
npm install @solana/web3.js @solana/spl-token
npm install -D typescript tsx @types/node

Two tiny helper files keep the later scripts short. The first connects to devnet and gives any keypair free test SOL:

// devnet.ts
import { Connection, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";
 
export const connection = new Connection("https://api.devnet.solana.com", "confirmed");
 
export async function fund(kp: Keypair, sol = 1) {
  const sig = await connection.requestAirdrop(kp.publicKey, sol * LAMPORTS_PER_SOL);
  const latest = await connection.getLatestBlockhash();
  await connection.confirmTransaction({ signature: sig, ...latest });
}

The faucet is rate limited, so if an airdrop fails, wait a minute and try again. The second helper is explained in the next section.

Lamports: tiny coins, whole numbers

A lamport is the smallest piece of SOL. One SOL is 1,000,000,000 lamports. When you send 0.1 SOL, the chain never stores 0.1. It moves the integer 100000000. Think of a piggy bank full of tiny coins: you never hold "a tenth of a coin", you just count coins. Decimals are only for display.

Why integers? Because floating point cannot represent most decimals exactly:

0.1 + 0.2; // 0.30000000000000004

Real money systems avoid that by storing the smallest unit. If you have used Razorpay, you already do this: a charge of ₹303.33 is sent as 30333 paise.

System You see Stored value Decimals
Razorpay ₹303.33 30333 paise 2
Solana 0.1 SOL 100000000 lamports 9
USDC on Solana 25.5 USDC 25500000 base units 6

Here is a helper that converts text to base units with no float math at all. It works for SOL (9 decimals) and for any token:

// units.ts
export function toBaseUnits(text: string, decimals: number): bigint {
  if (!/^\d+(\.\d+)?$/.test(text)) throw new Error("Not a valid amount");
  const [whole, frac = ""] = text.split(".");
  if (frac.length > decimals) throw new Error(`At most ${decimals} decimal places`);
  return BigInt(whole + frac.padEnd(decimals, "0"));
}
 
export function fromBaseUnits(units: bigint, decimals: number): string {
  const s = units.toString().padStart(decimals + 1, "0");
  const whole = s.slice(0, s.length - decimals);
  const frac = s.slice(s.length - decimals).replace(/0+$/, "");
  return frac ? `${whole}.${frac}` : whole;
}
 
console.log(toBaseUnits("0.1", 9)); // 100000000n
console.log(toBaseUnits("25.5", 6)); // 25500000n
console.log(fromBaseUnits(5000n, 9)); // 0.000005, one signature fee

A good rule for your own apps: store lamports or token base units as a BIGINT column, and format only when showing a number to a human.

Accounts: everything lives in one kind of box

On Solana, everything is an account. Programs are stateless code, and all state lives in separate accounts that get passed in. Every account has the same fields:

Field Meaning
lamports Its SOL balance
data A byte array where state is stored (can be empty)
owner The program allowed to change this account's data
executable true if the account holds program code

There are three common flavours:

  1. Wallet account: lamports, no data, owned by the System Program. Only the private key holder can spend from it.
  2. Data account: lamports and data. A token mint, a token balance or a game state lives here, owned by the program that manages it.
  3. Program account: executable is true and the data is compiled code.

You can ask the RPC server to decode an account for you. Here is the USDC mint:

curl -s -X POST https://api.mainnet-beta.solana.com \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getAccountInfo",
    "params": [
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      { "encoding": "jsonParsed" }
    ]
  }'

With jsonParsed, the response includes the mint's supply, decimals and authorities as readable fields, and the owner is the SPL Token Program. And here is a small script that sorts any address into one of the three flavours:

// classify.ts
import { Connection, PublicKey, SystemProgram } from "@solana/web3.js";
 
const main = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
 
async function classify(address: string) {
  const info = await main.getAccountInfo(new PublicKey(address));
  if (!info) return "empty, nothing lives here";
  if (info.executable) return "program";
  if (info.owner.equals(SystemProgram.programId) && info.data.length === 0) return "wallet";
  return `data account owned by ${info.owner.toBase58()}`;
}
 
const samples = [
  "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC mint
  "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // SPL Token Program
];
for (const a of samples) console.log(a, "=>", await classify(a));

Paste any wallet from Solscan into samples to see the "wallet" case too.

Why accounts hold lamports: rent exemption

Storing bytes on every validator costs something, so each account must hold a minimum balance based on its size. In practice every account is rent exempt, and the deposit is refundable when you close the account.

import { connection } from "./devnet";
 
const bytes = 165; // size of an SPL token account
const lamports = await connection.getMinimumBalanceForRentExemption(bytes);
console.log(`${bytes} bytes needs ${lamports} lamports`); // about 0.002 SOL

SOL versus custom tokens

SOL is the native token. It lives directly in the lamports field, the System Program moves it, and no smart contract is needed. It pays fees, secures the network through staking and funds rent deposits.

Custom tokens (USDC, USDT, BONK and every memecoin) exist only because the SPL Token Program defines their rules. Picture a factory and a locker room: the mint is the factory that defines the token, and each holder has a token account, a locker that records the mint, the owner and the amount.

SOL SPL token
Where is the balance? lamports of your wallet amount inside a token account
Who moves it? System Program SPL Token Program
Can it pay fees? Yes No, you always need SOL
Who creates it? The protocol Anyone, by creating a mint

That last row bites people: a wallet with 1,000 USDC and 0 SOL cannot send a single transaction.

Fees: three small parts

Every transaction asks all validators to check signatures and run code. A fee puts a price on that work so nobody can flood the network.

  • Base fee: a flat 5,000 lamports per signature (0.000005 SOL). It does not rise with congestion.
  • Compute units (CUs): Solana's gas units. The default is 200,000 per instruction and the maximum is 1,400,000 per transaction. Run out and the transaction fails.
  • Priority fee: optional, priced in micro-lamports per CU.
priority fee in lamports = CU limit x price in micro-lamports / 1,000,000

The priority fee uses the CU limit you request, not what you use, so a tight limit saves money. For example, 200,000 CUs at 100,000 micro-lamports costs 20,000 lamports, which is still only 0.00002 SOL.

Where does it go? Half of the base fee is burned and half goes to the validator. The whole priority fee goes to the validator, a change from SIMD-0096 in early 2025. Older articles say half of it is burned, and that is no longer true.

Fees stay low because block space is plentiful relative to demand. They only climb for contested accounts, like a hyped token launch, where people bid priority fees to win the race.

Send SOL, then play fee detective

This script sends 0.1 SOL with an explicit CU limit and price. Then it reads the transaction back from the chain and splits the fee into its parts, so you can check the maths yourself:

// transfer-sol.ts
import {
  ComputeBudgetProgram,
  Keypair,
  LAMPORTS_PER_SOL,
  SystemProgram,
  Transaction,
  sendAndConfirmTransaction,
} from "@solana/web3.js";
import { connection, fund } from "./devnet";
 
const sender = Keypair.generate();
const receiver = Keypair.generate();
await fund(sender);
 
const tx = new Transaction().add(
  ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000 }),
  ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 50_000 }),
  SystemProgram.transfer({
    fromPubkey: sender.publicKey,
    toPubkey: receiver.publicKey,
    lamports: LAMPORTS_PER_SOL / 10,
  }),
);
const signature = await sendAndConfirmTransaction(connection, tx, [sender]);
 
// Fee detective: read the real numbers from the chain
const info = await connection.getTransaction(signature, {
  maxSupportedTransactionVersion: 0,
  commitment: "confirmed",
});
const fee = info!.meta!.fee;
const base = 5_000 * info!.transaction.signatures.length;
 
console.log("total fee    :", fee); // 5050
console.log("base fee     :", base); // 5000
console.log("priority fee :", fee - base); // 50
console.log("CUs used     :", info!.meta!.computeUnitsConsumed);

The priority part is 1,000 CUs times 50,000 micro-lamports divided by 1,000,000, which is 50 lamports. Change the limit and price, predict the total, then run it again. Also try sending a much bigger amount: the fee stays the same, because it pays for work and signatures, not for the amount moved.

Transactions and instructions

An instruction is a command for one program. It has three parts:

  1. Program ID: which program should run it.
  2. Accounts: every account it will read or write, flagged as signer and or writable.
  3. Data: a byte array only that program knows how to decode.

A transaction bundles one or more instructions with signatures and a recent blockhash. It is atomic: either every instruction succeeds or none of them do. That is what makes "swap, then stake the result" safe as a single step.

SystemProgram.transfer is a wrapper. Here is the same instruction built by hand, so the three parts are visible:

import { PublicKey, SystemProgram, TransactionInstruction } from "@solana/web3.js";
 
function transferIx(from: PublicKey, to: PublicKey, lamports: bigint) {
  const data = Buffer.alloc(12);
  data.writeUInt32LE(2, 0); // System Program "Transfer" is instruction number 2
  data.writeBigUInt64LE(lamports, 4); // amount as a little endian u64
 
  return new TransactionInstruction({
    programId: SystemProgram.programId, // 1. program id
    keys: [
      { pubkey: from, isSigner: true, isWritable: true }, // 2. accounts
      { pubkey: to, isSigner: false, isWritable: true },
    ],
    data, // 3. bytes
  });
}

Why list the accounts up front?

If the sender and receiver are already in the data, why declare them again? Because of parallelism. Since every transaction says which accounts it touches and whether it writes, validators can tell instantly which ones conflict. Transactions that write the same account go one after the other. Everything else can run at the same time on different CPU cores. This runtime is called Sealevel.

Transactions that touch different accounts run side by side

It also explains why hyped token launches get congested: thousands of people try to write to the same account, those writes cannot run in parallel, and so they compete with priority fees.

Custom tokens: your own mint in a few lines

On Solana you do not deploy a new program to make a token. You create a mint account managed by the shared SPL Token Program and choose your own rules. Launchpads like pump.fun automate exactly this.

// create-token.ts
import { Keypair } from "@solana/web3.js";
import {
  AuthorityType,
  createMint,
  getAccount,
  getOrCreateAssociatedTokenAccount,
  mintTo,
  setAuthority,
  transfer,
} from "@solana/spl-token";
import { connection, fund } from "./devnet";
import { fromBaseUnits, toBaseUnits } from "./units";
 
const payer = Keypair.generate();
const friend = Keypair.generate();
await fund(payer, 2);
 
// 6 decimals, like USDC. The payer is the mint authority.
const mint = await createMint(connection, payer, payer.publicKey, null, 6);
 
// Every holder needs a token account (the locker)
const mine = await getOrCreateAssociatedTokenAccount(connection, payer, mint, payer.publicKey);
const theirs = await getOrCreateAssociatedTokenAccount(connection, payer, mint, friend.publicKey);
 
await mintTo(connection, payer, mint, mine.address, payer, toBaseUnits("1000", 6));
await transfer(connection, payer, mine.address, theirs.address, payer, toBaseUnits("25.5", 6));
 
// Lock the supply forever: nobody can mint more
await setAuthority(connection, payer, mint, payer, AuthorityType.MintTokens, null);
 
const bal = await getAccount(connection, theirs.address);
console.log("friend holds:", fromBaseUnits(bal.amount, 6)); // 25.5

A few things to notice:

  • Same integer rule as lamports. The mint's decimals only tells apps where to put the dot.
  • Tokens live in token accounts, not in your wallet account. Each new account needs a small SOL rent deposit, so the payer needs SOL.
  • The mint authority is a trust signal. Whoever holds it can print new supply. Setting it to null, as in the last step, fixes the supply forever. Check this before buying a random token.

Stablecoins: a normal token with a promise

A stablecoin is a custom token pegged to a currency, usually the US dollar. USDC, USDT and PYUSD are the big ones. The token mechanics are identical to the one you just made. What is special is the off chain promise that keeps it worth $1.

Token Mint address on Solana
USDC EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
USDT Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB

For a fiat backed coin like USDC, the rule is simple: mint when dollars come in, burn when dollars go out. Every coin in circulation is matched by reserves such as cash and short term treasuries. Most people never mint directly, since that is for institutions. They buy USDC on an exchange or swap into it.

How a fiat backed stablecoin is minted and burned

Because USDC is just an SPL mint, you can read its supply yourself:

import { Connection, PublicKey } from "@solana/web3.js";
 
const main = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
const supply = await main.getTokenSupply(
  new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
);
 
console.log(supply.value.amount); // integer string of base units
console.log(supply.value.decimals); // 6
console.log(supply.value.uiAmountString);

That is the supply on Solana only. The total across all chains is larger, and it changes daily, so check a live source such as DefiLlama before quoting a number.

Quick answers

What if the issuer's bank fails? The peg is only as strong as the reserves. In March 2023, Circle had part of its reserves at Silicon Valley Bank when it collapsed, and USDC traded well below $1 for a few days.

Does swapping USDC for USDT on Jupiter mint or burn anything? No. A swap only moves tokens between you and liquidity providers. Neither supply changes.

Are stablecoins multichain? Yes, but "USDC on Solana" and "USDC on Ethereum" are separate mints backed by the same reserves.

How do I move one between chains? With a bridge. Circle's CCTP burns USDC on the source chain and mints it on the destination, so no wrapped copies exist. Wormhole and Mayan are other options. Bridges are heavily attacked, so prefer burn and mint routes and never bridge more than you can afford to lose.

Quick reference

Concept One line
Lamport 1 SOL is 10^9 lamports, and the chain stores integers only
Account lamports, data, owner, executable
Program An account with executable set to true
SPL token Rules from the SPL Token Program, balance in token accounts
Base fee 5,000 lamports per signature, half burned
Priority fee CU limit times micro-lamport price, all to the validator
Instruction Program ID, accounts, data bytes
Transaction Atomic bundle of instructions with signatures
Stablecoin A custom token minted and burned against real reserves

Try it yourself

  1. Change the price in transfer-sol.ts to 0, then to 1_000_000. Predict the total fee before you run it.
  2. Create a token with 9 decimals and a supply of 1 billion. What is the raw integer amount?
  3. After revoking the mint authority, try mintTo again and read the error.

References


Last updated: October 3, 2026

Enjoyed this? Let's talk

I write about backend, engineering and web3 as I learn them. Always happy to compare notes.

Keep reading