Solana-Data-Model

Solana

Everything in solana is an account

Account

1
2
3
4
5
6
7
8
{
"key" : "The account address, public key, unique ID" ,
"lamports" : "account balance" ,
"data" : "some data stored" ,
"executable" : "whether the stored data is code",
"owner" : "the Public key of the owner"
/*The owner has read-write-credit-withdraw access, others can only read-credit */
}

Programs

Solana programs are just accounts which is executable. Their data field store eBPF byte code.

  • All programs are stateless, they can only operate other accounts, not themselves.
  • Programs can execute instructions(parameters) and send instructions to other programs
  • If a program operate many accounts, it is done in a parallel way.

Instructions (aka parameters, arguments)

1
2
3
4
5
6
7
8
9
10
11
Instruction : {
program_id : "The target program of the instruction",
keys : [Account1, Accounts2 , ...] , //All the accounts involved in this execution
data : "raw bytes, other arguments" // actions + argumetns
}

Account : {
"key" : "public key of account" ,
is_mutable : bool ,
is_signed : bool
}

Transactions

Transaction can have multiple instructions in it. The transaction is what you send to the blockchain network.

1
2
3
4
5
6
7
8
9
10
{
message : {
instructions : [Ins1 , Ins2 , ....],
recent_blockhash : "used for prevent de-duplication",
fee_payer : "which account pays the transaction fee",
...
}
signers : "raw bytes, signed version of transaction, used for verification"

}

System Programs

System Programs are like C libraries or GNU toolset created by Solana Lab which you can use to facilitate your development

image-20240726223437810

NFT

NFT is actually SPL token!

1
2
3
4
5
{
decimal : 0 ,
total_supply : 1 ,
metadata : "highly customizable"
}