Create your own
Lesson illustration

Managing Program Upgrade Authority

Hello! Welcome back to our module on "Advanced Anchor and Program Lifecycle."

In our last session, we covered the mechanics of upgrading a program's executable code using the solana program deploy command. A recurring theme was the need for "upgrade authority" to perform these actions. Today, we'll demystify this critical concept. You will learn what the upgrade authority is, why it holds so much power, and how to manage it effectively using the Solana CLI. Mastering this is fundamental to secure and responsible program ownership on Solana.

What is the Upgrade Authority?

On Solana, programs deployed with the default BPFLoaderUpgradeable loader are, as the name suggests, upgradeable. The upgrade authority is simply the public key of the keypair that is authorized to perform these upgrades. It's a specific attribute of the on-chain program account.

When you first deploy a program, if you don't specify an upgrade authority, it defaults to the keypair you're using to pay for the transaction.

Let's start with a resource that explains the role of the upgrade authority and its significance.

How Is a Solana Program Deployed and Upgraded

This article from SEC3, a blockchain security firm, provides a clear overview of the Solana program deployment process and highlights the attributes of a program account, including the all-important upgrade authority.

Please read the sections 'Solana Program Account' and 'On Upgrading a Solana Program'. Focus on understanding that the upgrade authority is a designated address that has the power to change the program's code.

As the article emphasizes, the ability to upgrade a program is a powerful feature, allowing for bug fixes and new features. But this power is concentrated in the hands of the upgrade authority.

The "Super Power" of the Upgrade Authority

It's crucial to understand just how much control the upgrade authority has. It's not just about pushing new features. An entity with this authority can replace the existing program code with anything.

How Is a Solana Program Deployed and Upgraded

Let's revisit the same article to focus on the security implications, which are paramount for any serious developer.

Read the subsection titled '1. The Upgrade Authority Has Super Power'. This short but vital section explains why the security of this key is non-negotiable.

If the private key for the upgrade authority is compromised, an attacker could:

  • Replace your program with malicious code that steals funds from users.
  • Update the program to a broken state, effectively bricking your application.
  • Close the program account entirely, making it unusable.

Given your background in leading development teams, you can appreciate that managing this "root access" is a top-priority security concern. Now, let's look at the practical commands for managing it.

Viewing and Changing the Upgrade Authority

Your first step in managing authority is identifying who currently holds it. The Solana CLI provides a straightforward command for this.

Deploy a Solana Program with the CLI

The official Solana documentation details the CLI commands for all aspects of program management. We'll start with how to inspect a program's current state.

Read the section 'Showing a program account'. Pay close attention to the example output and the description of the Authority field.

As you can see, running solana program show <PROGRAM_ID> gives you a clear readout, including the public key of the current upgrade authority.

Now, for the main event: how do you change it? You might need to transfer authority from your personal developer wallet to a more secure option, like a hardware wallet or a multi-signature (multisig) wallet controlled by a team.

The command for this is solana program set-upgrade-authority. Let's examine how it works.

Deploy a Solana Program with the CLI

This next section in the Solana docs provides the exact syntax for transferring authority.

Read the section 'Set a program's upgrade authority'. Note the different command variations for specifying the current and new authorities. Most importantly, understand the purpose of the --skip-new-upgrade-authority-signer-check option.

Let's break down the core command:

solana program set-upgrade-authority <PROGRAM_ADDRESS> \
  --upgrade-authority <CURRENT_AUTHORITY_KEYPAIR> \
  --new-upgrade-authority <NEW_AUTHORITY_PUBKEY>
  • <PROGRAM_ADDRESS>: The public key of the program you're managing.
  • --upgrade-authority: A path to the keypair file of the current authority. This signature proves you have the right to make this change.
  • --new-upgrade-authority: The public key of the new authority.

By default, Solana requires a signature from both the current and new authorities. This is a safety mechanism to prevent you from accidentally transferring control to a key you don't possess (e.g., due to a typo in the address).

However, what if the new authority is an offline hardware wallet or a multisig program that can't co-sign the transaction interactively? This is where the --skip-new-upgrade-authority-signer-check flag is essential. It tells the runtime to only verify the signature of the current authority.

Test your understanding!

You are the lead developer of a new Solana project. For security, you want to transfer your program's upgrade authority from your personal file-based wallet (dev.json) to a new multisig wallet address MSigxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. You run the following command:

solana program set-upgrade-authority <PROGRAM_ID> --new-upgrade-authority MSigxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The command hangs, waiting for a second signature. Why is this happening, and what flag should you add to the command to make it succeed?

Show answer

The command is waiting for a signature from the new authority (MSig...) because that is the default, safe behavior. However, a multisig wallet is a program and cannot sign a CLI transaction directly.

To proceed, you need to add the --skip-new-upgrade-authority-signer-check flag. The correct command would be:

solana program set-upgrade-authority <PROGRAM_ID> --new-upgrade-authority MSigxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --skip-new-upgrade-authority-signer-check

This tells Solana to only require the signature from your default fee-paying wallet (which is assumed to be the current authority in this shortened command), completing the transfer.

Making a Program Immutable: The Final Step

Sometimes, the best way to manage authority is to relinquish it entirely. By making a program immutable, you permanently revoke the ability for anyone to upgrade it. This is a powerful signal to your users that the code they are interacting with is final and cannot be changed, providing the highest level of trust.

This action is irreversible. Once a program is immutable, it can never be upgraded again, even to fix a bug.

Deploy a Solana Program with the CLI

The same documentation page also covers how to make a program immutable.

Read the short section on 'Immutable programs'. Note that this can be done either at deployment or at any time later using the set-upgrade-authority command with a special flag.

To make a program immutable, the current upgrade authority simply needs to run:

solana program set-upgrade-authority <PROGRAM_ADDRESS> --final

After this transaction is confirmed, the program's upgrade authority is set to none, and it is locked forever.

A Professional Workflow for Authority Management

Let's tie this all together into a realistic lifecycle for a project:

  1. Development (Devnet/Testnet): You, the developer, hold the upgrade authority in a local file-based wallet. This allows for rapid iteration. Authority = my-wallet.json.
  2. Pre-Launch (Mainnet): The program is audited. Your team sets up a 3-of-5 multisig wallet (e.g., using Squads or SPL Governance). You execute solana program set-upgrade-authority ... --new-upgrade-authority <MULTISIG_PUBKEY>. Now, no single person can upgrade the program.
  3. Maintenance: A bug is found. An upgrade transaction is created and proposed to the multisig. At least 3 of the 5 keyholders must sign the transaction to authorize the deployment of the fix.
  4. Maturity/Decentralization: The project is considered complete and stable. To maximize user trust and decentralize control, the multisig wallet executes solana program set-upgrade-authority ... --final. The program is now a permanent, immutable public good on Solana.

Conclusion

You now have a comprehensive understanding of what the upgrade authority is and how to manage it. This is not just a technical exercise; it's a fundamental aspect of blockchain governance and security.

Key Takeaways:

  • The upgrade authority is the keypair with the exclusive right to change a program's on-chain code.
  • This authority is extremely powerful and its private key must be secured. A compromised key can lead to a total loss of user funds.
  • You can view the current authority with solana program show <PROGRAM_ID>.
  • You can transfer the authority using solana program set-upgrade-authority ... --new-upgrade-authority <NEW_PUBKEY>. For institutional-grade security, the new authority should be a multisig wallet.
  • You can permanently revoke the upgrade authority and make a program immutable with the --final flag. This action is irreversible.

Preview of the Next Lesson

We've now thoroughly covered the lifecycle of a program's code. In our next lesson, we will circle back to the topic of data. We'll move beyond the simple versioning we discussed earlier and explore more advanced strategies for migrating on-chain account data when you have complex changes, ensuring a seamless evolution for your program's state and your users' experience.

Can't find a good explanation? Sign up and we'll make it for you

Sign up