Solana Interview Questions - Easy

Easy-level Solana interview questions covering blockchain basics, programs, and development.

Q1: What is Solana and how does it work?

Answer:

Solana is a high-performance blockchain designed for scalability.

Key Features:

  • High Throughput: 65,000+ TPS
  • Low Latency: ~400ms block time
  • Low Cost: ~$0.00025 per transaction
  • Proof of History: Cryptographic time ordering
  • Tower BFT: Practical Byzantine Fault Tolerance

Architecture:

  • Validators: Produce blocks and validate
  • Programs: Smart contracts (on-chain code)
  • Accounts: Store data and SOL
  • Transactions: Instructions executed atomically

Q2: What are Solana programs and how do you write them?

Answer:

Solana Programs are smart contracts written in Rust.

Basic Program Structure:

 1use solana_program::{
 2    account_info::AccountInfo,
 3    entrypoint,
 4    entrypoint::ProgramResult,
 5    pubkey::Pubkey,
 6    msg,
 7};
 8
 9// Entry point
10entrypoint!(process_instruction);
11
12pub fn process_instruction(
13    program_id: &Pubkey,
14    accounts: &[AccountInfo],
15    instruction_data: &[u8],
16) -> ProgramResult {
17    msg!("Hello, Solana!");
18    
19    // Process instruction
20    Ok(())
21}

Program Types:

  • System Program: Basic operations
  • Token Program: SPL tokens
  • Custom Programs: Your own logic

Deploy Program:

1# Build program
2cargo build-bpf
3
4# Deploy
5solana program deploy target/deploy/my_program.so

Q3: What are Solana accounts and how do they work?

Answer:

Account Structure:

1pub struct Account {
2    pub lamports: u64,           // Balance in lamports
3    pub data: Vec<u8>,            // Account data
4    pub owner: Pubkey,            // Program owner
5    pub executable: bool,          // Is executable program
6    pub rent_epoch: u64,          // Rent epoch
7}

Account Types:

  • System Accounts: Owned by system program
  • Program Accounts: Owned by programs
  • PDA (Program Derived Address): Deterministic addresses

Account Data:

  • Accounts store state
  • Programs own accounts
  • Accounts pay rent

Q4: How do you create and send transactions on Solana?

Answer:

Transaction Creation:

 1// Using @solana/web3.js
 2import { Connection, Keypair, Transaction, SystemProgram } from '@solana/web3.js';
 3
 4// Create transaction
 5const transaction = new Transaction().add(
 6    SystemProgram.transfer({
 7        fromPubkey: fromKeypair.publicKey,
 8        toPubkey: toPubkey,
 9        lamports: 1000000, // 0.001 SOL
10    })
11);
12
13// Sign and send
14transaction.sign(fromKeypair);
15const signature = await connection.sendTransaction(transaction, [fromKeypair]);

Transaction Structure:

  • Instructions: Operations to perform
  • Signatures: Required signatures
  • Recent Blockhash: Prevents replay

Q5: What is the Solana Program Library (SPL)?

Answer:

SPL Programs:

  • Token Program: Create and manage tokens
  • Token Swap: AMM for token swaps
  • Stake Pool: Staking pools
  • Name Service: Domain names

Using SPL Token:

 1use spl_token::instruction as token_instruction;
 2
 3// Create token
 4let create_ix = token_instruction::initialize_mint(
 5    &spl_token::id(),
 6    &mint_pubkey,
 7    &mint_authority,
 8    None,
 9    9, // decimals
10)?;

Q6: How does Solana achieve high throughput?

Answer:

Performance Features:

  1. Proof of History: Cryptographic time ordering

    • Eliminates need for validators to agree on time
    • Enables parallel processing
  2. Tower BFT: Optimized consensus

    • Faster than traditional BFT
    • Reduces communication overhead
  3. Gulf Stream: Transaction forwarding

    • Validators know transactions in advance
    • Reduces confirmation time
  4. Sealevel: Parallel execution

    • Executes transactions in parallel
    • Uses all CPU cores
  5. Pipelining: Multiple stages

    • Transaction processing pipeline
    • Overlaps different stages

Q7: How do you interact with Solana using web3.js?

Answer:

Basic Interaction:

 1import { Connection, PublicKey, Keypair } from '@solana/web3.js';
 2
 3// Connect to cluster
 4const connection = new Connection('https://api.mainnet-beta.solana.com');
 5
 6// Get balance
 7const balance = await connection.getBalance(publicKey);
 8
 9// Get account info
10const accountInfo = await connection.getAccountInfo(publicKey);
11
12// Send transaction
13const signature = await connection.sendTransaction(transaction, [signer]);

Reading Data:

1// Get program accounts
2const accounts = await connection.getProgramAccounts(programId);
3
4// Get transaction
5const tx = await connection.getTransaction(signature);

Q8: What are Program Derived Addresses (PDAs)?

Answer:

PDA are deterministic addresses derived from program ID and seeds.

Creating PDA:

1use solana_program::pubkey::Pubkey;
2
3// Find PDA
4let (pda, bump_seed) = Pubkey::find_program_address(
5    &[b"my_seed", user_pubkey.as_ref()],
6    program_id,
7);

PDA Properties:

  • Deterministic: Same seeds = same address
  • No private key: Controlled by program
  • Used for: Program-owned accounts

Use Cases:

  • Escrow accounts
  • Token vaults
  • Program state

Q9: How does Solana handle fees and rent?

Answer:

Transaction Fees:

  • Base fee: 0.000005 SOL (5000 lamports)
  • Compute units: Additional fee for compute
  • Priority fees: Optional for faster processing

Rent:

  • Accounts must maintain minimum balance
  • Rent exempt: Accounts with enough balance
  • Rent collection: Inactive accounts lose rent

Rent Calculation:

1let rent = Rent::default();
2let rent_exempt_minimum = rent.minimum_balance(data_len);

Q10: How do you test Solana programs?

Answer:

Testing with Anchor:

 1#[cfg(test)]
 2mod tests {
 3    use super::*;
 4    use anchor_lang::prelude::*;
 5    
 6    #[test]
 7    fn test_my_program() {
 8        let program = anchor_lang::solana_program::program::Program::new(
 9            program_id,
10            &program_data,
11        );
12        
13        // Test instruction
14        let result = program.process_instruction(
15            &program_id,
16            &accounts,
17            &instruction_data,
18        );
19        
20        assert!(result.is_ok());
21    }
22}

Local Testing:

1# Start local validator
2solana-test-validator
3
4# Run tests
5anchor test

Related Snippets