Posts

Showing posts from May, 2025

Account Model

In Solana, especially when using Anchor , an account model refers to the way data is stored on- chain . Unlike traditional databases, Solana doesn’t use tables— it uses accounts , and each account stores structured binary data 🔹 What is an Account in Solana? A Solana account is a piece of memory on- chain that: Has a public key Holds data ( if it’s not executable) May be owned by a program ( smart contract) Can be mutable or immutable May be rent- exempt or rent- paying 🔹 Account Model in Anchor With Anchor, you define account structures using the #[account] macro. These are your on- chain models. Example: ```#[account] pub struct VoteAccount {     pub voter: Pubkey,     pub choice: u8,     pub timestamp: i64, }``` 🔹 #[derive(Accounts)] → Instruction Context This is used to define the context ( i. e., required accounts) for a program instruction .     ``` #[derive(Accounts)] pub struct Initialize<'info> {   ...

IDL (Interface Definition Language)

  In Solana Anchor , an IDL ( Interface Definition Language) file is a JSON description of your smart contract that includes: Program name & address Instructions ( methods your program exposes) Accounts ( data layout for on- chain accounts) Types ( custom types or structs used) Events & Errors ( if any) The IDL is automatically generated by Anchor and is used by clients ( like web frontends or scripts) to interact with your smart contract easily — similar to an ABI in Ethereum. When you anchor build IDL file is generated.

Rent in Solana

 Rent refers to the fee required to maintain accounts on the network.  To make an account rent- exempt— meaning it won't be purged for inactivity— you must deposit a minimum balance of lamports ( the smallest unit of SOL) based on the account's size. Once you deploy the project with proper space allocated, you no longer need to pay for rent as it is already pre paid. If the space that is allocated exceeds then the project may be purged for inactivity.