Skip to Content

๐Ÿ“ฆ Accounts

On Solana, accounts are the units of on-chain state. They hold SOL (lamports), arbitrary data, and an owner (a program that can modify them). There are no โ€œcontract storageโ€ slots like on the EVM โ€” everything is an account.


๐ŸŽฏ Why Accounts Matter

  • Everything is an account โ€” Program code, user data, token balances, NFT metadata
  • Explicit in instructions โ€” Every instruction lists which accounts it reads/writes; the runtime enforces permissions
  • Rent โ€” Accounts must hold enough SOL to be rent-exempt or they can be reclaimed

๐Ÿ“š Account Structure

From the Solana docsย :

FieldDescription
lamportsBalance in lamports (1 SOL = 10^9 lamports)
ownerProgram ID that can modify this account
dataOpaque byte array (layout defined by the owner program)
executableWhether the account is program code
rent_epochUsed for rent calculation

Only the owner program can change the accountโ€™s data or assign a new owner. Clients and other programs pass account references in each instruction.


๐Ÿ“ Reading an Account (Node / @solana/web3.js)

import { Connection, PublicKey } from "@solana/web3.js"; const connection = new Connection("https://api.devnet.solana.com"); const address = new PublicKey("YourAccountPubkey..."); const accountInfo = await connection.getAccountInfo(address); if (accountInfo) { console.log("Owner:", accountInfo.owner.toBase58()); console.log("Lamports:", accountInfo.lamports); console.log("Data length:", accountInfo.data.length); // Data layout depends on the program (e.g. Metaplex, SPL Token) }

๐Ÿ“ Account Sizes and Rent

  • Rent-exempt minimum โ€” Accounts below a size threshold must hold enough lamports to be rent-exempt. See rentย .
  • Closing โ€” When an account is no longer needed, a program can close it and send the lamports to a specified account (e.g. user).

๐Ÿ”— Resources

Last updated on