Accounts => Everything is an account!!!
- Unique 256-bit address.
- Hold some balance of SOL.
- Can store arbitrary data.
- Data Storage is paid with Rent.
Anyone can credit SOL or read data.
Only the account's owner can debit SOL or modify data.
{
key: number, // The address of the account
lamports: number, // Lamports currently held
data: Uint8Array, // Data stored in the account
is_executale: boolean, // Is this data a program
owner: PublicKe // the program with write access
}
//Lamports: This is the unit of currency
in Solana (similar to “wei” in Ethereum).
Accounts hold lamports, which can be converted to SOL, Solana's native currency. 1 SOL is equal to 1,000,000,000 lamports it same as Satoshi on BTC. Data: This is a section where the account can store information.
Programs = Smart contracts
Smart contracts on Solana are called "programs"
- Language written in Rust, C/C++, Python.
- Data is eBPF bytecode (ebpf bite code which is the Berkeley packet filter bite code
Special kind of account
Programs are stateless: they read & write data to other accounts
This allows programs to be executed in parallelMust be the owner of an account to modify
Programs process instructions
Programs can send instructions to other programs using called cross program invocation or CPI
{
program_id: number, // program this instruction is for
keys: Arry<{ // actions involved in the instraction
key: PublicKey,
is_mutable: boolean,
is_signer: boolean,
}>,
data: Uint8Array, // action +args
}
Transactions
Transaction => RPC Client => Network
{
message: {
instructions: Array<Instraction>, // list of instructions
recent_blockhash: number, // de-duplication
fee_payer: PublicKey, // pays "gas" fee
...
},
signers: Array<Uint8Array>, // signed version of trasaction
}
Transactions:
Transactions are the vehicles through which instructions are executed on the Solana blockchain. A transaction consists of multiple components:
Instructions: These are the individual actions that a transaction aims to perform. Each instruction specifies the program it's intended for, the accounts involved, and any additional data or arguments necessary for the program to execute the instruction.
Recent Blockhash: This is a hash value derived from a recent block on the blockchain. It serves as a de-duplication mechanism, ensuring that transactions are not replayed or executed multiple times.
Fee Payer: Every transaction requires a fee to be paid in SOL, which compensates the validators for processing the transaction. The fee payer is the account responsible for paying this fee.
Signers: To authorize the execution of a transaction, it must be signed by one or more accounts. The signers array contains the cryptographic signatures of these accounts, proving their consent to the transaction.
Transactions are submitted to the Solana network through an RPC (Remote Procedure Call) client, which broadcasts the transaction to the validators responsible for processing and adding it to the blockchain.
+-------------+
| Client |
| (dApp UI) |
+-------------+
|
| User Action
| Triggers Transaction
v
+-------------+
| RPC Client |
+-------------+
|
| Routes Transaction
v
+-------------+
| Validator |
+-------------+
|
| Executes Instruction
v
+-------------+
| Program |
| (Smart |
| Contract) |
+-------------+
|
| Modifies State
v
+-------------+
| Counter |
| Account |
| count = 1 |
+-------------+
Top comments (0)