> 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mercurydata.app/retroshades/get-started/deploying-to-mercury-retroshades.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
