EVM vs. SVM: Smart Contracts

Learn the differences between Ethereum and Solana smart contracts.

Μπορείτε να γράψετε και να αναπτύξετε προγράμματα στο blockchain του Solana. Τα προγράμματα, γνωστά και ως έξυπνα συμβόλαια σε άλλα πρωτόκολλα, αποτελούν τη βάση για onchain δραστηριότητες που κυμαίνονται από DeFi και NFTs έως μέσα κοινωνικής δικτύωσης και παιχνίδια.

  • Programs process instructions received from users or other programs.
  • All programs do not maintain state. In other words, the data used by programs is sent to separate accounts through instructions.
  • The program itself is stored in an executable checked account.
  • All programs are owned by the BPF Loader and executed by the Solana Runtime.
  • Developers typically write programs in Rust or C++. However, any language targeting LLVM and BPF backend can be chosen.
  • All programs have a single entry point where instruction processing occurs (i.e., process_instruction). The following parameters are always included:
  • program_id: pubkey,
  • accounts: array,
  • instruction_data: byte array

Unlike most other blockchains, Solana completely separates data and code. All data that programs interact with is stored in separate accounts and is called through instructions.

This model allows for comprehensive single programs to operate through various accounts without the need for additional deployments. A common example of this pattern can be seen between Native and SPL Programs.

Native προγράμματα και η Βιβλιοθήκη Προγραμμάτων Solana (SPL)

Το Solana διαθέτει πολλά προγράμματα που λειτουργούν ως βασικά δομικά στοιχεία για onchain αλληλεπιδράσεις.

Αυτά τα προγράμματα χωρίζονται σε Native Programs και Solana Program Library (SPL) Programs.

Τα Native Programs παρέχουν τη θεμελιώδη λειτουργικότητα που απαιτείται για τη λειτουργία των validators. Ένα από τα πιο γνωστά προγράμματα μεταξύ αυτών είναι το System Program, υπεύθυνο για τη διαχείριση νέων λογαριασμών και τη μεταφορά SOL μεταξύ δύο ομάδων.

Τα SPL Programs υποστηρίζουν διάφορες onchain δραστηριότητες, συμπεριλαμβανομένης της δημιουργίας token, της ανταλλαγής, του δανεισμού, της δημιουργίας stake pool και των onchain υπηρεσιών ονομάτων. Το SPL Token Program μπορεί να κληθεί απευθείας μέσω του CLI. Άλλα προγράμματα, όπως το Associated Token Account Program, συνήθως διαμορφώνονται ως προσαρμοσμένα προγράμματα

Writing Programs

Programs are typically developed in Rust and C++. However, you can develop in any language targeting LLVM and BPF backend. Recent efforts by Neon Labs and Solang make EVM compatibility possible, allowing developers to write programs in Solidity.

Most Rust-based programs follow the architecture below:

FileDescription
lib.rsRegistering modules
entrypoint.rsEntrypoint to the program
instruction.rsProgram API, (de)serializing instruction data
processor.rsProgram logic
state.rsProgram objects, (de)serializing state
error.rsProgram-specific errors

Recently, Anchor has emerged as a framework for developing programs. Anchor reduces boilerplate and simplifies (de)serialization handling, similar to Ruby on Rails but for Rust-based programs. Programs are typically developed and tested in the Localhost and Devnet environments before being deployed to Testnet and Mainnet.

Solana supports the following environments:

Cluster EnvironmentRPC Connection URL
Mainnet-betahttps://api.mainnet-beta.solana.com
Testnethttps://api.testnet.solana.com
Devnethttps://api.devnet.solana.com
LocalhostDefault port: 8899 (e.g., http://localhost:8899)

Μόλις αναπτυχθούν σε ένα περιβάλλον, οι πελάτες μπορούν να αλληλεπιδρούν με onchain προγράμματα μέσω συνδέσεων RPC σε κάθε cluster.

Deploying Programs

Developers can deploy programs via the CLI as follows:

solana program deploy <PROGRAM_FILEPATH>

When a program is deployed, it is compiled into an ELF shared object (including BPF bytecode) and uploaded to the Solana cluster. Programs exist inside an account except when they are marked as executable and allocated to the BPF Loader. The account's address is used as the program_id to reference the program in all transactions.

Solana supports multiple BPF Loaders, including the recent Upgradable BPF Loader. BPF Loaders are responsible for managing program accounts and making this possible through the program_id for clients.

All programs have a single entry point where instruction processing occurs (i.e., process_instruction). The parameters always include:

  • program_id: pubkey
  • accounts: array
  • instruction_data: byte array

Once called, programs are executed by the Solana Runtime.

Summary

  • The Program in Solana corresponds to 'Executable account' on the Solana blockchain.
  • The concept of smart contracts in Ethereum aligns with the concept of programs in Solana.
  • Solana enables anyone to issue tokens without the need to deploy additional contracts.

Start building on Solana

Διαχειρίζεται από

© 2026 Ίδρυμα Solana.
Με επιφύλαξη παντός δικαιώματος.
Συνδεθείτε
EVM to SVM: Smart Contracts | Solana