• Developers can write and deploy programs on the Solana blockchain.
  • Program (referred to as Smart Contract in Ethereum Protocol)
  • The basic role of on-chain Horadong that supports everything such as Defi, NFT, Social Media, etc.
  • The program handles the commands of the end user and other programs
  • All programs are stateless, all data they interact with is stored in a separate account passed through commands
  • The program itself is stored in an account marked as executable
  • All programs are owned by BPF Loader and executed in Solana Runtime
  • Developers most commonly write Rust and C++ programs, but you can choose any language that targets BPF or LLVM in the backend.
  • Every program has a single entry point where instruction processing takes place. (i.e. Process_instruction)
  • program_id: pubkey
  • accounts: array,
  • instruction_data: byte array

Unlike other blockchains, Solana completely separates code and data.

  • All data with which the program interacts is stored in a separate account and -passed by reference through instructions.
  • This model allows a single generic program to operate on multiple accounts without further deployment.
  • Common examples of this pattern can be found in native and SPL programs.

Native Program, Solana Program Lib

  • It has several programs that serve as key building blocks for on-chain interactions.
  • The Natebee program provides the basic functions necessary to operate the validator.
  • The most well-known of these programs is the system program.
  • Responsible for managing new accounts and transferring SOLs between the two parties.
  • The SPL program supports a variety of on-chain activities including token creation, exchange and lending, creating stake pools and maintaining on-chain name services.
  • Can be called directly through the SPL token program, while others like the Associated Token Account Program are usually configured as user-defined programs.

Write Program

  • Programs are most commonly developed in Rust and C++, but can be developed in any language targeting LLVM and BPF backends.
  • It provides EVM activation compatibility such as Solidity and enables developers to write programs in Solidity.

Rust-based program architecture

File Description Registering Modules EntryPoint to the Program Program API, (de)serializing instruction data Program Objects, (de)serializing Program-specific erros
  • Recently, Anchor (similar to Ruby on Rails) is a unique framework that reduces usage and simplifies the (deserialization) process for Rust-based development.
  • Programs are generally developed and tested on Localhost and Devnet environments before being distributed to Testnet or Mainnet.
Cluster Env RPC Connection URL
Localhost default port: 8899

Program Deploy

  • Programs can be deployed through CLI.
    solana program deploy <PROGRAM_FILEPATH>
  • When the program is distributed, it is compiled into an ELF Sharing Object.
  • BPF Byte Code, upload to Solana Cluster
  • An Executable program exists in the account (very similar to everything else in Solana), except that this account is marked and assigned as a BPF Loader.
  • program_id is the address of your account, which will be used to refer to the program in all future transactions
  • Supports Upgradable BPF Loader, manages program account (program_id)
  • When called, the program is executed by Solana Runtime.

Other Resources