# Auto Restore Plugin

<figure><img src="https://1878311582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrN5WLmmo14XNSVjsb16D%2Fuploads%2FXfQrPId52xmvt0IPJ79o%2Fimage.png?alt=media&#x26;token=0e99b002-7043-41f8-8065-b6ff7021e8db" alt=""><figcaption></figcaption></figure>

The Auto Restore plugin can be used to automatically perform a restore transaction whenever a soroban transaction simulation identifies archived states that would interfere with the transaction execution.

For further details on this scenario, refer to Soroban's official documentation on [State Archival](https://soroban.stellar.org/docs/soroban-internals/state-archival).

* Pipeline Type: [simulate-transaction](https://docs.cheesecakelabs.com/stellar-plus/reference/core/pipelines/simulate-transaction "mention")
* Supported Pipelines:&#x20;
  * [simulate-transaction](https://docs.cheesecakelabs.com/stellar-plus/reference/core/pipelines/simulate-transaction "mention")
  * [soroban-transaction](https://docs.cheesecakelabs.com/stellar-plus/reference/core/pipelines/soroban-transaction "mention") - Targets its inner pipeline.
  * [classic-transaction](https://docs.cheesecakelabs.com/stellar-plus/reference/core/pipelines/classic-transaction "mention")- Targets its inner pipeline.

## Setup

Constructor arguments:

* **restoreTxInvocation**: An object of a Transaction Invocation to parametrize the restore transaction. If a Fee Bump header is present, the transaction will use the [Fee Bump plugin](https://docs.cheesecakelabs.com/stellar-plus/reference/utils/plugins/fee-bump-plugin) to wrap the transaction with this header.
* **networkConfig**: A network configuration. Refer to [constants](https://docs.cheesecakelabs.com/stellar-plus/reference/constants "mention")
* **customRpcHandler**: An optional custom RPC handler to be used for this transaction.

## postProcess

During the `postProcess` of the Simulate Transaction pipeline, the Auto Restore plugin will verify if the response of the simulation indicates a restore is required. In case yes, it will perform the following steps:

1. Extract the restorePreamble from the simulation
2. Build a restore transaction with its parameters and the restorePreamble
3. Execute the transaction
4. Verify if the original transaction's source was the same as the restore transaction and bumps its sequence number if necessary.

Afterward, the Simulation Pipeline will proceed with the `postProcess` step before exiting.
