Introduction to Solana Programs
On the Solana blockchain, "smart contracts" are referred to as programs. These programs are deployed on-chain within accounts that contain compiled executable binaries. Users interact with programs by submitting transactions containing specific instructions that dictate the program's actions.
Key Characteristics of Solana Programs
- Executable Code: Programs are accounts housing executable code, structured into functions called instructions.
- Stateless Design: While programs themselves are stateless, they can create and update other accounts to store data.
- Upgradability: Programs can be updated by a designated upgrade authority. Once this authority is revoked, the program becomes immutable.
- Verifiable Builds: Users can verify that an on-chain program's data matches its public source code through verifiable build processes.
Developing Solana Programs
Solana programs are primarily written in Rust, with two main development approaches:
1. Anchor Framework
Anchor is a specialized framework for Solana program development that simplifies the process through Rust macros, reducing boilerplate code. It's particularly recommended for beginners due to its streamlined approach.
2. Native Rust Development
For those seeking more flexibility, programs can be written in Rust without frameworks. This native approach offers greater control but requires deeper expertise in Rust and Solana's architecture.
Program Deployment and Upgrades
Solana programs are compiled using LLVM into ELF files containing Solana's custom sBPF (Solana Bytecode Format) bytecode. These binaries are stored on-chain in executable accounts upon deployment.
๐ Learn more about Solana program deployment
Upgrade Process
Programs can be modified by their designated upgrade authority, typically the original deployer. When this authority is revoked (set to None), the program becomes permanently immutable.
Verifiable Builds
The Solana ecosystem supports tools for verifying that on-chain programs match their published source code:
- Solana Explorer: Search for program addresses to check verification status.
- Solana Verifiable Build CLI: A tool by Ellipsis Labs for independent verification.
- Anchor Support: Built-in verifiable build functionality in the Anchor framework.
Loader Programs
Every Solana program is owned by its loader program. Current loader programs include:
| Loader | Program ID | Notes |
|---|---|---|
| Native | NativeLoader1111111111111111111111111111111 | Owns other loaders |
| BPFLoader v1 | BPFLoader1111111111111111111111111111111111 | Legacy loader |
| BPFLoader v2 | BPFLoader2111111111111111111111111111111111 | Current standard |
| BPFLoader v3 | BPFLoaderUpgradeab1e11111111111111111111111 | Being phased out |
| BPFLoader v4 | LoaderV411111111111111111111111111111111111 | Future standard |
Loaders enable essential program management functions like deployment, upgrades, and authority transfers.
Precompiled Programs
Signature Verification Programs
| Program | Program ID | Description |
|---|---|---|
| Ed25519 | Ed25519SigVerify111111111111111111111111111 | Ed25519 signature verification |
| Secp256k1 | KeccakSecp256k11111111111111111111111111111 | Secp256k1 public key recovery |
| Secp256r1 | Secp256r1SigVerify1111111111111111111111111 | Secp256r1 signature verification |
These programs provide efficient cryptographic operations crucial for transaction validation.
๐ Explore Solana's cryptographic programs
Core Solana Programs
The Solana genesis includes several essential core programs:
| Program | Program ID | Function |
|---|---|---|
| System Program | 11111111111111111111111111111111 | Account creation and management |
| Vote Program | Vote111111111111111111111111111111111111111 | Validator voting management |
| Stake Program | Stake11111111111111111111111111111111111111 | Stake delegation management |
| Config Program | Config1111111111111111111111111111111111111 | Chain configuration storage |
| Compute Budget Program | ComputeBudget111111111111111111111111111111 | Compute resource management |
Frequently Asked Questions
What's the difference between Solana programs and smart contracts?
Solana uses the term "programs" instead of "smart contracts," but they serve similar purposes. Programs are executable code deployed on-chain that process instructions from user transactions.
How can I verify a Solana program's authenticity?
You can use Solana Explorer to check verification status or tools like the Solana Verifiable Build CLI to independently verify program binaries against published source code.
What programming language is best for Solana development?
Rust is the primary language for Solana program development, with the Anchor framework being particularly beginner-friendly. For applications interacting with programs, JavaScript/TypeScript is commonly used.
Can Solana programs be upgraded after deployment?
Yes, programs can be upgraded if they have an active upgrade authority. Once this authority is revoked, the program becomes immutable.
What are loader programs used for?
Loader programs manage the lifecycle of other programs, handling deployment, upgrades, and authority management. All Solana programs are owned by their respective loaders.