> For the complete documentation index, see [llms.txt](https://docs.mercurydata.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mercurydata.app/retroshades/get-started/deploying-to-mercury-retroshades.md).

# Deploying to Mercury Retroshades

## Compiling with the Mercury flag

Before deploying to the Retroshades network, you need to build the binary that holds retroshades logic:

```bash
cargo build --release --target wasm32-unknown-unknown --features mercury
```

## Deploying

From the `mercury-cli` directory:

{% code overflow="wrap" %}

```bash
./target/release/mercury-cli --base https://mainnet.mercurydata.app/rest \
  --jwt "$JWT" \
  deploy \
    --project example-retroshade \
    --code-path ../retroshades-data-directory/hello_world/target/wasm32-unknown-unknown/release/soroban_hello_world_contract.wasm \
    --contracts 'CNEWCON...'
```

{% endcode %}

The retroshade contract will be executed in real time when `--contracts` are executed. You can target one or more smart contracts for a single retroshade contract.

Deploying with a `--project` name that already exists returns a `409 Conflict`. Use a unique project name per deployment, or delete the existing one first.

## Adding contracts to an existing program

To append additional contract IDs to an already-deployed program without redeploying:

```bash
curl -X POST https://mainnet.mercurydata.app/rest/retroshade/append-contracts \
  -H "Authorization: Bearer <yourjwt>" \
  -H "Content-Type: application/json" \
  -d '{
    "program_id": 1,
    "contracts": ["CNEWCON..."]
  }'
```

This is append-only -- contracts already associated with the program cannot be removed individually. Sending a contract ID that is already registered returns `409 Conflict`.

## Deleting a program

Deletes the program and drops all associated retroshade tables (`retroshade.program_{id}_*`). This is irreversible.

```bash
curl -X DELETE https://mainnet.mercurydata.app/rest/retroshade/1 \
  -H "Authorization: Bearer <yourjwt>"
```

Only the owner of the program can delete it.

## Backfills

Use the backfill feature to retroactively process historical ledgers for a deployed program. Backfills currently run on demand. Contact the Mercury team for access.
