# Programs

{% hint style="info" %}
For web3 native teams, the "Programs" section will be a part of the core operations of their Squad and it allows to:

* Add programs
* Upgrade Programs
* Change authority of programs
  {% endhint %}

### Create and add programs

{% hint style="info" %}
Users can add programs to manage and upgrade them directly from their Squad.
{% endhint %}

{% embed url="<https://youtu.be/TbVDUWZW0Sg>" %}

#### Create programs

1. Create and deploy a program using your CLI.

#### Add programs

1. Navigate to the "Programs" section within your Squad's vault. Then click on "Add Progra&#x6D;*".*

&#x20; 2\. Enter the name and address of the program. Click "Next" and verify the transaction in the wallet pop-up.

<figure><img src="https://1205508290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOJv2Locm6v5eywwSeaG%2Fuploads%2FbI3jYOcMS6iuIac3Ozyp%2Fprograms%202.png?alt=media&#x26;token=8c0ed7f0-671b-4f6b-85ce-6e50a34cbb50" alt=""><figcaption><p>Add program pop-up</p></figcaption></figure>

3\. Set the program’s upgrade authority to the address provided: copy the program authority update code and paste it into your CLI. The CLI code should be run by the current authority. Then click “Verify authority”.

<figure><img src="https://1205508290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOJv2Locm6v5eywwSeaG%2Fuploads%2F7sLaw8djw5XPSQ66avGr%2Fprograms%203.1.png?alt=media&#x26;token=502e2756-3f10-485a-9061-7b64006d699b" alt=""><figcaption><p>Add program pop-up</p></figcaption></figure>

{% hint style="warning" %}
**NOTE:** If the current authority is managed by a DAO or wallet you may need to set the authority by other means using the provided upgrade authority.
{% endhint %}

{% hint style="info" %}
For users who would want to perform the authority transfer in a safer way there is an option to make a Safe Authority Transfer (SAT).&#x20;

SAT creates a transaction in the Squad, which needs to be signed by both Squad's Vault PDA and the current authority holder.
{% endhint %}

{% embed url="<https://youtu.be/tnllbW3yX14>" %}

**To perform a Safe Authority Transfer (SAT):**

1. Add your CLI wallet to the Squad. Check the [Owners and Setting](https://docs.squads.so/squads-v3-docs/navigating-your-squad/owners-and-settings) page for more info on members addition.
2. Click on the "Create SAT" button.
3. Enter a description (optional) and run a transaction inside your Squad.&#x20;
4. Once the transaction meets the confirmation threshold, execute it with your CLI wallet, which you added into your Squad.&#x20;
5. Once the transaction is executed, your program authority will be transferred.

<figure><img src="https://1205508290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOJv2Locm6v5eywwSeaG%2Fuploads%2FqpQEYZihdNw1R0aiEvc7%2Fprograms%203.2.png?alt=media&#x26;token=4bc4073d-6076-4eea-9335-ab69bf8abee4" alt=""><figcaption><p>Safe Authority Transfer (SAT)</p></figcaption></figure>

### Upgrade a program&#x20;

{% hint style="info" %}
Once the program is added to a Squad it can be upgraded straight from your Squad.
{% endhint %}

{% embed url="<https://youtu.be/IQMkyslQy4E>" %}

**To upgrade a program:**

1. Deploy your upgrade to the buffer using the command below. (For Rust)&#x20;

```
solana program write-buffer <PROGRAM_FILEPATH>
```

{% hint style="info" %}
For more information about writing intermediary buffer accounts refer to the link: <https://docs.solana.com/cli/deploy-a-program#using-an-intermediary-buffer-account>&#x20;
{% endhint %}

2\. Click on the program from the list and then click on the "Add upgrade" button.

3\. Insert the details of the upgrade: name, buffer, and spill address, then click "Next" and approve the transaction in the wallet pop-up.

<figure><img src="https://1205508290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOJv2Locm6v5eywwSeaG%2Fuploads%2FprWC4ykTvDc6aKeC71b7%2Fprograms%204.png?alt=media&#x26;token=22ad16d3-802e-4972-9322-07aa42c12b1e" alt=""><figcaption><p>Program upgrade pop-up</p></figcaption></figure>

4\. Set the authority of the buffer to the provided address by copying a code in your CLI. Then click “Verify authority”.

<figure><img src="https://1205508290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOJv2Locm6v5eywwSeaG%2Fuploads%2FdFqqNoTtFxwnufghJmtv%2Fprograms%205.png?alt=media&#x26;token=51dcf154-b7a8-4dc5-a5a7-727b5c67554f" alt=""><figcaption><p>Program upgrade pop-up</p></figcaption></figure>

5\. Click on the "Upgrade" button. A transaction will be created, after it meets the confirmation threshold and gets executed, a program upgrade will be deployed.&#x20;

{% hint style="info" %}
Using actions created by [Cardinal](https://www.cardinal.so/), you can automate the deployment of program upgrades directly from Github. Using those actions you can automatically build code, deploy it to a buffer and create a program upgrade transaction inside your Squad every time you make code changes to your program.

**For more details check:**&#x20;

1. <https://github.com/marketplace/actions/squads-program-upgrade>
2. <https://github.com/cardinal-labs/solana-buffer-deploy-action>&#x20;

Squads users can also use [Nosana](https://nosana.io/) to create an automated deployment pipeline and streamline their deployment process.

**For more details check:**

1. <https://docs.nosana.io/tutorials/solana-multisig.html#cleaning-up-canceled-deployments>&#x20;
   {% endhint %}

### Remove a program from UI

{% hint style="info" %}
Users can remove programs that they no longer use from the UI and claim back the rent in SOL.
{% endhint %}

{% embed url="<https://youtu.be/QkOc78UqAYc>" %}

**To do this:**

1. Navigate to the programs list and click on the "Bin" icon next to the program you want to delete.&#x20;
2. Insert a description (optional) and launch a transaction.&#x20;
3. A program will be deleted upon transaction execution.

{% hint style="warning" %}
This action does not affect the program or the buffer, it will only remove the program from the UI. It will also return the PDA rent (in SOL) of this account to your vault.
{% endhint %}

### Withdraw program upgrade authority

{% hint style="info" %}
Program authority can be changed directly from a Squad after a program was added to any other address if needed.&#x20;
{% endhint %}

**To do this:**

1. Click on the program from the programs list.
2. Click on the "Change authority" button.
3. Insert a new program authority address and initiate a transaction.&#x20;
4. Program authority will be changed upon transaction execution.&#x20;
