SummaryPrograms deployed via loader-v3 can be upgraded when an upgrade authority is
set. Revoking the authority makes the program immutable. Covers the upgrade
mechanism, loader-v3 deployment and upgrade instructions, build verification,
and the available loader programs.
Deploying programs
Native Rust
Deploy using the Solana CLI with
solana program deploy.Anchor
Deploy using the Anchor framework with
anchor program deploy.Upgrading programs
To upgrade a program, an account must hold the upgrade authority (typically the account that originally deployed the program). During deployment or upgrade, new bytecode is uploaded to a temporary buffer account, then written to the program data account. Setting the upgrade authority toNone makes the program immutable and permanently prevents further
updates.
Upgrade mechanism
WhenUpgradeableLoaderInstruction::Upgrade
is processed, the runtime:
- Verifies the Program account is writable and owned by loader-v3.
- Verifies the Buffer account contains a
Bufferstate with the correct authority. - Verifies the ProgramData account’s
upgrade_authority_addressmatches and is notNone. - Verifies the program was not already deployed in the current slot
(
clock.slot != slot). - Loads and verifies the new ELF bytes from the buffer.
- Copies the new bytecode from the buffer into the ProgramData account and zeros remaining bytes.
- Funds the ProgramData account to rent-exemption.
- Drains the buffer account (sets lamports to 0) and truncates its data.
- The new version becomes effective in the next slot (
deployment_slot + 1).
Program account itself (its state and the programdata_address pointer)
does not change during an upgrade. Only the ProgramData account’s bytecode
and slot metadata are updated.
Loader-v3 instruction reference
Loader-v3 (BPF Loader Upgradeable) is the current default loader for deploying programs on Solana.| Instruction | Description |
|---|---|
InitializeBuffer | Sets a buffer account’s state to Buffer with the specified authority. Fails if already initialized. |
Write | Writes bytes at the specified offset in a buffer account. Authority must sign. |
DeployWithMaxDataLen | Creates a new program: derives the ProgramData address, creates the ProgramData account via CPI to System Program, verifies and deploys the ELF from the buffer, sets the Program account’s state, and marks it executable. |
Upgrade | Replaces the bytecode in an existing program’s ProgramData account from a buffer. |
SetAuthority | Changes the authority of a Buffer or ProgramData account. Setting to None on ProgramData makes the program immutable. Buffer authority cannot be set to None. |
SetAuthorityChecked | Like SetAuthority, but requires the new authority to also sign the transaction. |
Close | Closes a buffer, uninitialized, or ProgramData account by transferring its lamports to a recipient. Closing ProgramData also writes a Closed tombstone to the program cache. Cannot close a program that was deployed in the current slot. |
ExtendProgram | Extends the ProgramData account’s allocation by additional bytes. Permissionless: no authority signs, and the payer funds the extra rent. Since SIMD-0431, each call must add at least 10,240 bytes, unless it extends the account to the maximum size. solana program extend and solana program deploy (when an upgrade needs more space) send this instruction. |
ExtendProgramChecked | Like ExtendProgram, but the upgrade authority must sign. Feature-gated: the feature is inactive on Mainnet and Devnet, so the instruction fails with InvalidInstructionData. |
Verifying programs
Solana supports verifiable builds, which let users confirm that a program’s onchain bytecode matches its public source code. The Anchor framework provides built-in support for verifiable builds. To check verification status for a deployed program, search for its program ID on the Solana Explorer, or use the Solana Verifiable Build CLI to independently verify onchain programs.Loader programs
| Loader | Address | Upgradeable | Description |
|---|---|---|---|
| Native Loader | NativeLoader1111111111111111111111111111111 | Only via validator software upgrade | Owns builtins (System, Vote, Compute Budget) and other loaders |
| BPF Loader (v1) | BPFLoader1111111111111111111111111111111111 | No (loader management disabled) | Legacy programs |
| BPF Loader (v2) | BPFLoader2111111111111111111111111111111111 | No (loader management disabled) | Legacy programs |
| BPF Loader Upgradeable | BPFLoaderUpgradeab1e11111111111111111111111 | Yes, if upgrade authority is set | Owns all newly deployed programs |