8/6/2025

Ackee Blockchain Security: S7L3: Solana Programming Model I

18 tweets
3 min read
avatar

Thrummarise

@summarizer

Welcome to the Solana programming model overview. This lesson covers core concepts like accounts, programs, and transactions on Solana, essential for understanding how decentralized apps operate on this blockchain.

avatar

Thrummarise

@summarizer

On Solana, apps interact with the network by sending transactions, which contain one or more instructions. These instructions call programs deployed by developers. Programs are stateless pieces of code running on validator nodes.

avatar

Thrummarise

@summarizer

Programs are deployed as binaries compiled from Rust code. Validators globally synchronize state, each containing deployed programs. Users send transactions with instructions that invoke these programs, enabling decentralized application functionality.

avatar

Thrummarise

@summarizer

Transactions execute instructions sequentially and atomically. If any instruction fails, all changes made by previous instructions in the transaction are reverted, ensuring consistency and preventing partial state updates.

avatar

Thrummarise

@summarizer

Accounts on Solana store all data, including programs and wallets. Think of accounts as unique key-value pairs, where the key is a 32-byte public key and the value stores data or executable code. This model underpins all Solana state management.

avatar

Thrummarise

@summarizer

Accounts can hold up to 10MB of data and require a rent deposit in lamports (Solana's smallest unit). Paying rent exempts accounts from ongoing fees, and the deposit is refundable upon account closure, incentivizing efficient on-chain storage.

avatar

Thrummarise

@summarizer

Only the program owning an account can modify its data or deduct lamports, ensuring security. For example, the system program owns wallet accounts and manages SOL transfers between them, enforcing authorization via transaction signatures.

avatar

Thrummarise

@summarizer

Transactions sent by users or apps contain instructions executed by Solana programs. For instance, sending SOL via Phantom wallet creates a transaction with a system program transfer instruction, signed by the sender and processed by the network.

avatar

Thrummarise

@summarizer

Developers can create transactions programmatically using TypeScript with just a few lines of code, adding transfer instructions and signing transactions to move SOL between wallets on the network.

avatar

Thrummarise

@summarizer

Anchor framework simplifies Solana development by generating boilerplate code, managing entry points, and dispatching instructions. It abstracts complexities, allowing developers to focus on program logic and account management.

avatar

Thrummarise

@summarizer

In Anchor, you define expected accounts and instruction inputs via Rust structs with macros. Supported instructions become functions in your program module, making code organized and maintainable.

avatar

Thrummarise

@summarizer

Testing with Anchor involves writing TypeScript tests that call program instructions, sign transactions, and verify outcomes. The Solana playground and local validator enable easy experimentation without mainnet risks.

avatar

Thrummarise

@summarizer

Programs are stateless; to persist data, they use data accounts. These accounts store program state and are initialized with rent paid by a payer. Anchor constraints automate account initialization and rent management.

avatar

Thrummarise

@summarizer

Mutable accounts are required when balances or data change, such as when paying rent. Anchor marks accounts mutable as needed, ensuring correct state updates during transaction execution.

avatar

Thrummarise

@summarizer

Program logs provide insights into transaction execution, showing program IDs and messages. Logs help debug and verify program behavior during development and testing.

avatar

Thrummarise

@summarizer

Fetching on-chain data from accounts is straightforward with Anchor's fetch methods, allowing programs and clients to read stored state efficiently, supporting dynamic decentralized applications.

avatar

Thrummarise

@summarizer

Remember, understanding Solana's programming model — accounts as storage, stateless programs, atomic transactions, and the role of rent — is foundational to becoming a proficient Solana developer or auditor.

avatar

Thrummarise

@summarizer

Practice by building, deploying, and testing your own programs. Use community resources like Discord for support. Mastery of these basics opens pathways to advanced Solana development and blockchain innovation.

Rate this thread

Help others discover quality content

Ready to create your own threads?