> ## Documentation Index
> Fetch the complete documentation index at: https://new-docs.squads.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Close Vault Transaction Account

## Overview

Reclaim rent from a rejected, cancelled, executed, or stale Vault Transaction. This instruction closes the transaction account and returns rent to the configured rent collector.

## Prerequisites

* Transaction that is rejected, cancelled, executed, or stale
* Rent collector set on the multisig
* `@sqds/multisig` package installed

## Quick Example

```typescript theme={null}
import * as multisig from "@sqds/multisig";
import { Connection, PublicKey } from "@solana/web3.js";

const ix = await multisig.instructions.vaultTransactionAccountsClose({
  multisigPda,
  // Must be the rent collector set on the multisig
  rentCollector,
  transactionIndex,
});
```

## When Rent Can Be Reclaimed

| Condition | Description |
| - | - |
| Rejected | Corresponding proposal status is Rejected |
| Cancelled | Corresponding proposal status is Cancelled |
| Executed | Transaction has been executed |
| Stale | `transactionIndex` ≤ `staleTransactionIndex`, and the proposal is Draft or Active or does not exist |

A Vault Transaction whose proposal is Approved cannot be closed, even if it is stale. Cancel the proposal first.

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `multisigPda` | `PublicKey` | Yes | PDA of the multisig |
| `transactionIndex` | `bigint` | Yes | Index of the transaction to close |
| `rentCollector` | `PublicKey` | Yes | Account to receive the reclaimed rent |
| `programId` | `PublicKey` | No | Squads program ID. Defaults to `multisig.PROGRAM_ID` |

## Full Example

```typescript theme={null}
import * as multisig from "@sqds/multisig";
import { Connection, PublicKey } from "@solana/web3.js"

async function main(member: PublicKey) {
    // Cluster Connection
    const connection = new Connection("<your rpc url>");

    // If you've saved your createKey, you can define it as a static PublicKey
    const createKey = new PublicKey("<your createkey>")

    // Derive the multisig PDA
    const [multisigPda] = multisig.getMultisigPda({
        createKey,
    });
    // or
    // const multisigPda = new PublicKey("<your multisig key>");

    // Get deserialized multisig account info
    const multisigInfo = await multisig.accounts.Multisig.fromAccountAddress(
      connection,
      multisigPda
    );

    // Get the current transaction index
    const transactionIndex = BigInt(multisigInfo.transactionIndex.toString());
    // or, if this is tied to your first transaction
    // const transactionIndex = 1n;

    // Rent can only be reclaimed if a rent collector is set on the multisig
    const rentCollector = multisigInfo.rentCollector;
    if (!rentCollector) {
        throw new Error("This multisig has no rent collector set");
    }

    const ix = await multisig.instructions.vaultTransactionAccountsClose({
        multisigPda,
        // This value must be the current rent collector Public Key of the Multisig.
        rentCollector,
        transactionIndex,
    });
}
```

## Error Handling

| Error | Cause | Solution |
| - | - | - |
| Transaction active | Transaction is not rejected, cancelled, executed, or stale | Wait for appropriate status |
| Invalid rent collector | Wrong rent collector address | Use the address configured on the multisig |
| Rent reclamation disabled | No rent collector set on the multisig | Set a rent collector with a Config Transaction |

## See Also

* [Vault Transaction Account](/developers/typescript-sdk/accounts/transactions#vault-transactions)
* [Multisig Account](/developers/typescript-sdk/accounts/multisig)
* [Reclaim Rent Guide](/developers/typescript-sdk/guides/reclaim-rent)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.