Accounts and Addresses
Accounts and addresses - the unit of state on Solana. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not. On-chain samples are Rust; client samples use TypeScript where noted.
Parse a base58 public key.
use solana_sdk :: pubkey :: Pubkey ;
use std :: str :: FromStr ;
let system = Pubkey :: from_str ( "11111111111111111111111111111111" ) . unwrap ();
system . to_string () . starts_with ( "111" ) // true
Describe accounts for an instruction.
// AccountMeta::new(pubkey, is_signer)
// AccountMeta::new_readonly(pubkey, is_signer)
Account privileges on the instruction.
// meta.is_signer / meta.is_writable flags
// runtime enforces signer and mutability
Well-known system program address.
// solana_sdk::system_program::id()
// 11111111111111111111111111111111
Accounts need enough lamports to be rent-exempt.
// Rent::default().minimum_balance(data_len)
Only the owner program may change account data.
// account.owner == program_id for program state
Programs are executable accounts.
// account.executable == true for program accounts
Balance in lamports (1 SOL = 1e9 lamports).
// 1_000_000_000u64 // 1 SOL
Account data is a byte vector.
Generate a new keypair (client/tools).
// let kp = Keypair::new();
// kp.pubkey()
⚠️ Important: Do not copy-paste Solana code into your app without doing your own quality/security audit. Code blocks are generic examples only for learning and experimentation in dev/testing environments, and may not be suitable for your app. This site is in BETA testing, and ongoing quality evaluation, so may have code errors. There is no warranty - see terms .
CreateWithSeed derived addresses (legacy).
// Pubkey::create_with_seed(&base, seed, &owner)
Practical account data size limits apply (10MB class constraints historically 10MB).
// keep state small; prefer PDAs per entity
Read Clock sysvar for slot/unix time.
// Clock::get()?.unix_timestamp
Rent sysvar parameters.
// Rent::get()?.lamports_per_byte_year
First account meta is often fee payer/signer.
// transaction fee payer must sign and be writable
Stack versions: This page was written for Agave 4.1.1 , Solana CLI 3.0.10 , Anchor 0.32.1 , Rust 1.91.1 , and @solana/kit 7.0.0 .