What is program (Solana)?

Solana's name for deployed on-chain code, the equivalent of a smart contract, except that programs are stateless and all their data lives in separate accounts.

Not yet verifiedHow we verify

3 min read

In this entry

Solana's name for deployed on-chain code, the equivalent of a smart contract, except that programs are stateless and all their data lives in separate accounts.

Each program may touch only the accounts a transaction names. Many core functions, including the token program and the stake program, are shared programs maintained as system software rather than per-project deployments.

If you come from Ethereum, the separation of code from state is the thing to internalize. An Ethereum contract holds its own balances and variables at its own address. A Solana program holds nothing; it is executable code that reads and writes accounts owned by it, and those accounts are separate entries in the ledger with their own addresses and their own rent deposits.

How it works

  1. Code is deployed to an account marked executable. That account holds the compiled program and nothing else.
  2. State lives elsewhere. Data sits in ordinary accounts whose owner field names the program. Only the owning program may modify them. Deterministic addresses derived by a program are called program derived addresses. See pda.
  3. Transactions declare their accounts. Every transaction lists in advance each account it will read or write, and whether it needs write access (source: the Solana documentation).
  4. The runtime schedules on that basis. Because the account set is known before execution, transactions touching disjoint accounts can run at the same time. This is where the chain's throughput comes from. See parallel execution.
  5. Upgrades are explicit. A program is deployed either as immutable or under an upgrade authority key, and which one applies is visible on chain.

Shared system programs handle the common cases. Token balances are not held by each project's own contract but by the token program, which is why an spl token balance lives in a token account rather than in a per-token ledger.

Example

Sending an SPL token illustrates the split. Your wallet address does not hold the token. A separate token account, owned by the token program and associated with your wallet, holds the balance. A transfer names your token account, the recipient's token account, and the token program, and the runtime rejects it if any required account is missing from the list.

The practical consequence shows up in your balance. Opening a token account requires a rent-exempt deposit, an illustrative fraction of a SOL, which is refunded if you close the account later. That is why a wallet may show slightly less spendable SOL than its total: part of it is deposited against accounts you own.

Why it matters when you buy

Before depositing into any Solana application, checking whether its program is immutable or upgradeable tells you whether the code you reviewed is the code that will run tomorrow. That is a five-second check on an explorer. How to use a block explorer covers the technique, verifying a token contract covers the token side, and the chain pages put Solana's throughput next to alternatives.

smart contract — the general equivalent; pda — deterministic program-owned addresses; parallel execution — why declared accounts matter; rent — the deposit accounts must hold; spl token — balances held by the token program; upgradeable contract — logic that can be replaced.

Questions

Is a program the same as a smart contract?

Functionally yes, structurally no. Both are on-chain code anyone can call, but a Solana program stores no state of its own and operates on accounts passed into each transaction.

Why does a transaction have to list every account?

So the runtime can tell in advance which transactions conflict. Two transactions writing to different accounts cannot interfere, so they run at the same time. Declaring the accounts is what makes that determination cheap.

How do I tell if a program can be changed?

An explorer shows whether the program account is immutable or has an upgrade authority, and which key holds it. An immutable program cannot be altered by anyone; an upgradeable one can be replaced by whoever controls that key.