Play with Solana, master the core concept of Solana

In 2024, Solana’s unusually emerged, TVL soared from one billion US dollars at the beginning of the year to nearly 5 billion US dollars today, and became the fourth largest public chain.

Compared with Ethereum, Solana has brought a better experience to users at a faster speed and lower cost.Its POH -based consensus mechanism and asynchronous transaction execution model provides developers with high throughput and low -delayed blockchain performance, becoming the preferred platform for various decentralized applications.

>

BlockSec special planning“Play to Solana”The series of articles covers the basic concepts of Solana, viewing and analyzing the practical guidelines of Solana trading, and writing SOLANA smart contract tutorials.

As the first phase of this series, this article will introduce the key concepts in the Solana network, including its operating mechanism, account model and transaction, to write the foundation for the correct and efficient Solana contracts for everyone.

EBPF: The execution cornerstone of Solana transaction

In order to write and execute smart contracts, blockchain often requires a computing environment of programming languages ​​and Turing.

Friends who are familiar with Ethereum should know that smart contracts on Ethereum usually use high -level language Solidity to write, while the byte code compiled by Solidity is running in an environment called Ethereum virtual machine.

Solana did not choose to develop a new virtual environment and language, but made full use of existing excellent technologies.EBPF (Extended Berkeley Packet Filter) virtual machines that were originally used to expand the Linux kernel function were selected by Solana as the underlying execution environment.

So, what are the advantages of EBPF compared to EVM?

Compared with the EVM that only supports the explanation execution, the EBPF can directly convert the bytecode into a machine instruction in the processor in the real -time compilation (JIT) mode, thereby running the program more efficiently.

EBPF has a set of efficient instruction sets and mature infrastructure.Developers only need to use the Rust language to write smart contracts.The LLVM compilation framework provides a backend of EBPF, using it to directly compile the program written by these Rust language into the byte code that can run on the EBPF virtual machine.

Solana’s account model

1. Solana account structure

The data on Solana is stored in the form of an account.As shown in the figure below, we can regard all the data in Solana as a huge key value to the database.The key to the database is the address of the account, for the “wallet” account (that is,

For Solana users through public private keys for direct control over the account), this address is a public key generated using the ED25519 signature system; the value of the database is the specific information of the account, including balance and other related information.

>

Solana uses a structure called accountinfo to describe an account, which is composed as shown in the figure below.

>

Each account in Solana contains four fields.Here we explain it one by one.

  • Data fieldData related to the account are stored.If the account is a program (that is, a smart contract), it is actually the EBPF bytecode.Otherwise, the information format in Data is generally defined by the founder of the account.

  • Executable fieldIt is used to identify whether the account is a program.It should be noted that unlike Ethereum, the program in Solana can be updated.

  • LAMPORTS fieldRecord the balance of the account Solana token.LAMPORTS is actually the smallest unit of SOL token (1 SOL = 1 billion LAMPORTS).

  • Owner fieldInstructed the owner of the current account.In Solana, any account has a “owner”.For example, the owner of all “wallets” account is System Program, which is a special account on the Solana network, responsible for account creation and other functions.The account owner is the only person who can modify the account data and deduct the Lamports balance (but anyone can increase Lamports, that is, execute the transfer function to the account).

2. Stopy -of -meaning Solana account

Solana has a set calledNative programsThe predetermined running program is deployed on a fixed address.With the upgrade of the Solana network, these predefined programs may also be updated.We can understand these programs as APIs and library functions that provide specific functions under the Solana network.

In Native Programs, developers often need to interact with it.System ProgramEssenceSystem Program provides developers with some instructions, and we can understand each instruction as an independent method.For example, developers can use the CreateAccount instruction to create a new account, or use the Transfer instruction to transfer Lamports to other accounts.

Another common Native Programs is a BPF loader program.It is the owner of all other program accounts, which is responsible for deployment, updating and executing specific procedures.When a “wallet” account needs to update its deployed program, it is actually completed by commissioning the BPF Loader program. After all, only the program owner has direct permissions to modify the data.

In addition to Native Programs, Solana also provides a setSysvarAccount.They provide information and global variables related to the current Solana network status, such as the current clock, the nearest block hash, etc.

3. Account rent

On the Solana chain, each account needs to maintain a certain number of Lamports as the minimum quota, which is calledrentEssenceUnlike the concept of rent in real life, the rent on Solana can be recovered.In order to ensure that the data of the account on the chain is available, the account needs to hold the corresponding amount of Lamports.The amount of rent is related to the size of the account storage space on the chain.

Any transaction attempting to deduct the account balance to below the amount of rent will fail, unless the transaction directly deducts the balance of the account to zero.This operation indicates that the rent of the account has been recovered. At the end of the transaction execution, Solana will be recovered by garbage to clear the storage space of the corresponding account.

What’s more?View “Solana account” in the browser

In order to lead everyone to better understand the relevant concepts, we use the “Hello World” project provided by Solana to create a program account. You can view it through Solana’s blockchain browser Solscan to viewThe following accountWhat’s more?Related information.

CJWHXB4QEWBV9EGYUKTN881BNDMDKLBZH1FMDWQLLHOE

>

As shown in the figure above, we can first see that the account has been marked by the Solana browser as “Program”.When creating the account, some Lamports are deducted from the balance of the sender as the rent of the account. Therefore, we can see that its Sol Balance field is not empty.

Secondly, because we create a program, its Executable field is yes.There may be a difficult thing here, that is, readers may find that the data field stores an address rather than the EBPF program.We mentioned earlier that Solana allows update programs, and it is actually implemented through a “proxy” mode.Since Solana does not allow direct modification of program accounts, it creates a data account to store the EBPF program, and the Data field of the program account only stores the address of the data account.Whenever you need to update the program, you only need to modify the Data field in the data account.We use Solscan to check the account of the Executable Data field. It can be found that it is marked as “Program Executable Data Account”. Its Data field stores the actual program:

>

Back to the previous picture, we can find that the Owner field in More Info is BPF Loader, which is consistent with our description in the previous section.

There is also a field called “Upgrade Authority” in OverView. What does it mean?

As we mentioned earlier, the “wallet” account is updated to update the program by commissioning BPF Loader. Before updating, BPF Loader needs to verify whether the client has the authority.Since the OWNER field of the program account is already BPF Loader, it has no room for storing the information, so Solana chooses to store this information in the data account of the data account.”Upgrade Authority” here.The figure below shows the relationship between the program account and the data account. You can see that the data field of the data account consists of two parts of the wallet address and EBPF code.

>

Solana’s transactions and instructions

In Solana, users also execute programs by issuing transactions.Its special thing is thatSolana can execute these transactions in parallelThis is also an important reason why it can provide lightning transactions.Next, let’s take a look at how Solana’s transactions are designed.

A SLANA transaction consists of the signature and message subject.A transaction can contain multiple signatures.The main body of the transaction is composed of four parts, as shown in the figure below.

>

NewsHead information(Header) andAccount address array(Compact Array of Account Addresses) The two fields specify the characteristics of all accounts and accounts involved in the transaction in transactions: whether the account provides signatures and whether it will be written during execution.Using this information, Solana can verify the signatures provided by the corresponding account and can execute those transactions that do not touch the same account collection in parallel.

NearestBlock(Recent Blockhash) is the timestamp of the transaction.The Solana network ensures that the transaction comes from the last 150 blocks, otherwise the transaction will be considered to expire and not be executed.

Instruction array(Compact Array of Instructor) is the most important part of the transaction and contains one or more instructions.A instruction is actually called a routine provided by a program.The instruction consists of three fields, as shown in the figure below:

>

The first field of Program ID index specifies the receiver of the instruction, that is, the chain program on the instruction needs to be processed.It does not directly store a 32 -byte address, but places the address in the account address array in the message subject.This field uses a bidding of a byte to indicate that its position in the array realizes a space reuse.

Similar to the first field, the second field is a compact array of account address indexes, which consists of the account address, which indicates that all the accounts involved in the instruction are specified.

The last field is an array of bytes. It is an additional information required by the program to process the instruction, which can understand it as a parameter of the function.

It should be noted that Solana will handle all the instructions in the transaction in order and ensure that the execution of the transaction is atom.This means that the instructions in a transaction are either failed or all successfully executed, and there will be no cases where some instructions are successfully executed and partial failure.

What’s more?View “Solana Transaction” in the browser

We use another Solana browser to viewCreate a transaction of a program account earlier?EssenceIn OverView, you can see the signatures of Solana transactions, recent block Hash and other information:
3UKQ85LPSNWB5D6CGUNTOMYJX3TSAEGB4PJUOMAMYNVQQNPP5PRG1kjeeek3yemZGMOJ5RowGon8Hzwl9d

>

In the Account Input, the characteristics of all accounts and related accounts involved in the current transaction are listed in transactions.We can see that in addition to senders, program accounts and other addresses, the two Native Programs and Sysvar accounts are also included.

>

Since the transaction is a simple program creation transaction, it only contains two instructions. The receiver of the first instruction isSystem Program, Responsible for creating a program account; the recipient of the second instruction isBpf loaderResponsible for writing the actual deployed EBPF code into the data account and the address of its address into the Data field of the program account.

>

Summarize

The smart contract on Solana is developed in Rust language and runs on the EBPF virtual machine.It follows the account model, and the account on the chain needs to maintain the rent to ensure the availability of the data.The transaction consists of one or more instructions, which clearly defines all the accounts that depend on, so that the transaction can be processed in parallel, increased throughput, and reduce the response delay.These characteristics jointly promote the rapid development of Solana and make it one of the popular blockchain platforms.

  • Related Posts

    The market is just a little bit better, WLFI is about to be unlocked

    Jessy, bitchain vision According to the official social media of World Liberty Financial (WLFI), it is developing a token transfer function. In mid-June this year, news that WLFI is about…

    From stock tokenization to Layer 2 Robinhood series new products quick look

    Written by: AIMan@Bitchain Vision On June 30, 2025, Robinhood released a series of new products at the Robinhood Presents: To Catch a Token event held in Cannes, France, which caused…

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You Missed

    Bitcoin is on the rise to 110,000 again. Is it a bullish return?

    • By jakiro
    • July 4, 2025
    • 4 views
    Bitcoin is on the rise to 110,000 again. Is it a bullish return?

    Wall Street pledge craze

    • By jakiro
    • July 3, 2025
    • 12 views
    Wall Street pledge craze

    Deconstructing Ethereum Fusaka Upgrade: The Expansion Evolution Theory Behind 12 EIPs

    • By jakiro
    • July 3, 2025
    • 11 views
    Deconstructing Ethereum Fusaka Upgrade: The Expansion Evolution Theory Behind 12 EIPs

    The market is just a little bit better, WLFI is about to be unlocked

    • By jakiro
    • July 3, 2025
    • 12 views
    The market is just a little bit better, WLFI is about to be unlocked

    Is AI “sinking” an opportunity for Web3?

    • By jakiro
    • July 2, 2025
    • 19 views
    Is AI “sinking” an opportunity for Web3?

    Grayscale: Stablecoin Summer

    • By jakiro
    • July 2, 2025
    • 16 views
    Grayscale: Stablecoin Summer
    Home
    News
    School
    Search