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

# Apex MEV Protection

> Turn on mevProtect to make OrbitFlare Apex skip leaders on the Shield blocklist, reducing sandwich risk for swaps. Works on JSON-RPC, HTTP, and QUIC.

## What It Does

Some validators are known to sandwich or otherwise exploit the transactions they receive. With MEV protection on, Apex **skips leaders on the Shield blocklist** when it forwards your transaction. The transaction waits for a leader that is not on the list rather than being handed to one that is.

The blocklist is an on-chain [Yellowstone Shield](https://github.com/rpcpool/yellowstone-shield) policy, so it is public and auditable.

## The Trade-Off

|                   | `mevProtect: false` (default)                             | `mevProtect: true`                                |
| ----------------- | --------------------------------------------------------- | ------------------------------------------------- |
| **Leaders used**  | Every leader                                              | Every leader except those on the Shield blocklist |
| **Landing speed** | Fastest                                                   | Can be slower by the blocklisted leaders' slots   |
| **Best for**      | Transfers, mints, liquidations, anything not sandwichable | Swaps and other price-sensitive trades            |

A leader produces 4 consecutive slots, about 1.6 seconds. When a blocklisted leader is up, a protected transaction waits out its turn. Make sure your blockhash has time left, and do not use protection as a substitute for a sensible slippage limit.

## How to Enable It

MEV protection is set per transaction over HTTP, and per connection over QUIC.

| Transport                       | Setting                                                                                                         |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| JSON-RPC `sendTransaction`      | Third param `true`                                                                                              |
| `POST /send`                    | `"mevProtect": true` in the JSON body                                                                           |
| `POST /send-bin`, `/send-batch` | Query flag `?mev_protect=1`                                                                                     |
| QUIC, Rust client               | `ClientOptions::mev_protect = true`                                                                             |
| QUIC, other languages           | `mev_protect` byte set to `1` in the [transaction packet](/apex/sending-transactions#quic-from-other-languages) |

In the samples below, `TX_BASE64` and the `apex-tx` helper come from [Sending transactions](/apex/sending-transactions#build-a-signed-tipped-transaction).

<CodeGroup>
  ```bash cURL theme={null}
  TX_BASE64=$(node apex-tx.mjs)

  # JSON-RPC: the third param is mevProtect.
  curl -s "$APEX_RPC" \
    -H "Content-Type: application/json" \
    -H "x-api-key: $APEX_API_KEY" \
    -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"sendTransaction\",\"params\":[\"$TX_BASE64\",{\"encoding\":\"base64\"},true]}"

  # Binary route: the mev_protect query flag.
  TX_BASE64=$(node apex-tx.mjs)
  echo "$TX_BASE64" | base64 --decode | curl -s "$APEX_RPC/send-bin?mev_protect=1" \
    -H "Content-Type: application/octet-stream" \
    -H "x-api-key: $APEX_API_KEY" \
    --data-binary @-
  ```

  ```javascript JavaScript theme={null}
  import { apexRpc, buildTx, confirm } from "./apex-tx.mjs";

  const tx = await buildTx({ label: "apex mev protect" });
  const signature = await apexRpc("sendTransaction", [
    Buffer.from(tx.serialize()).toString("base64"),
    { encoding: "base64" },
    true, // mevProtect
  ]);
  console.log("accepted:", signature);
  console.log("landed in slot", await confirm(signature));
  ```

  ```python Python theme={null}
  import base64

  from apex_tx import apex_rpc, build_tx, confirm

  tx = build_tx(label="apex mev protect")
  signature = apex_rpc("sendTransaction", [
      base64.b64encode(bytes(tx)).decode(),
      {"encoding": "base64"},
      True,  # mevProtect
  ])
  print("accepted:", signature)
  print("landed in slot", confirm(signature))
  ```

  ```rust Rust theme={null}
  // QUIC: protection is a connection option. Every send on this client is protected.
  use apex_sender_client::{ApexSenderClient, ClientOptions, Region};

  let client = ApexSenderClient::connect_with_options(
      ClientOptions {
          endpoint: Some(Region::Frankfurt.quic_endpoint()),
          mev_protect: true,
          ..Default::default()
      },
      &api_key,
  )
  .await?;
  let signature = client.send_transaction(&tx).await?;
  ```
</CodeGroup>

<Tip>
  In Rust, if you need both protected and unprotected sends, hold two clients: one with `mev_protect: true` and one without. Each keeps its own connection, and both stay warm.
</Tip>
