# Trade with MEV Protection

This section guides how users can perform MEV-protected transactions on Ethereum mainnet, be it swapping, token transferring, or liquidity provisioning, and will be achieved using Flashbots.&#x20;

<figure><img src="https://680235803-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaWFVt3vE2Ci7ngiL0xHe%2Fuploads%2FSphkiPmkYM19OOXgrGNa%2Fdiagram-export-02-02-2024-15_24_51.png?alt=media&#x26;token=7a5b3187-6535-46f6-9b6b-119b29fd2f42" alt="" width="375"><figcaption></figcaption></figure>

### Enabling MEV Protection involves passing the raw transaction generated from any of the blockchain POST transactions.

**API URL:** [`https://api.expand.network/chain/sendtransaction`](https://docs.expand.network/integrations/blockchains/evm-based-blockchains/ethereum#sendtransaction)

***

**Sample Request:**

```json
{
    "chainId":"1",
    "rawTransaction": "0xf8a68205180f82753e94dc31ee1784292379fbb2964b3b9c4124d8f89c6080b844a9059cbb000000000000000000000000a67e9b68c41b0f26184d64c26e0b2b81466e5994000000000000000000000000000000000000000000000000000000174876e8002ea0952b0468aff066f3e00a1d476b8894d84bfc47a1a3cdab9d6809a3461cc713e5a018219ee382aa3c7edf73a87bd8a75e2c40a97efbdf56a6cfd353af06fb74101d",
    "mevProtection": true
}
```

***

**Sample Response:**&#x20;

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "txHash": "0xd9cdf1483a85aa206625c66fea49059b96ffae1c086f76664cfa3f91a495d73a"
    }
}
```

### Users can fetch Flashbot blocks, transactions, and bundle data using the following endpoints:

**1. API URL**: [`https://api.expand.network/chain/getflashbotblocks`](https://docs.expand.network/integrations/blockchains/evm-based-blockchains/ethereum#getflashbotblocks)

**Sample Request:**

```url
https://api.expand.network/chain/getflashbotblocks?chainId=1
```

**Sample Response:**&#x20;

```json
{
  "status": 200,
  "msg": "success",
  "data": {
      "totalPages": "535",
      "currentPage": "509",
      "transactions":[
        {
          "block_signed_at": "2023-11-21T12:04:47Z",
          "block_height": 18620016,
          "block_hash": "0x1e424e1f2037a4a4bb89cc2614f5ebbba61612806f665f9c9c712a08d284c699",
          "tx_hash": "0xd57f92e13f0fad7d6a7540f55cc653d584793aea27be935c78df5759845eaad4",
          "tx_offset": 119,
          "successful": true,
          "miner_address": "0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5",
          "from_address": "0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5",
          "from_address_label": null,
          "to_address": "0x388c818ca8b9251b393131c08a736a67ccb19297",
          "to_address_label": null,
          "value": "25407585008794343",
          "value_quote": 49.371036777116664,
          "pretty_value_quote": "$49.37",
          "gas_metadata": {
              "contract_decimals": 18,
              "contract_name": "Ether",
              "contract_ticker_symbol": "ETH",
              "contract_address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "supports_erc": null,
              "logo_url": "https://www.datocms-assets.com/86369/1669653891-eth.svg"
          },
          "gas_offered": 32000,
          "gas_spent": 22111,
          "gas_price": 26280311476,
          "fees_paid": "581083967045836",
          "gas_quote": 1.1291398965184127,
          "pretty_gas_quote": "$1.13",
          "gas_quote_rate": 1943.1613339098476,
          "explorers": [
              {
                  "label": null,
                  "url": "https://etherscan.io/tx/0xd57f92e13f0fad7d6a7540f55cc653d584793aea27be935c78df5759845eaad4"
              }
          ]
      }
      ]
  }
}
```

***

**2. API URL**: [`https://api.expand.network/chain/getflashbottransactions`](https://docs.expand.network/integrations/blockchains/evm-based-blockchains/ethereum#getflashbottransactions)

**Sample Request:**

```url
https://api.expand.network/chain/getflashbottransactions?chainId=1
```

**Sample Response:**&#x20;

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "transactions": [
            {
                "transaction_hash": "0xbcf55b7e9488135c12f3e70bd2a191cc19913475de6937f54cb9843865416391",
                "tx_index": 0,
                "bundle_index": 21,
                "block_number": 18975317,
                "eao_address": "0x2aC74Bd02EE017fa05629432Dd3728720c455032",
                "to_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
                "gas_used": 30428,
                "gas_price": "10000002",
                "coinbase_transfer": "0",
                "eth_sent_to_fee_recipient": "0",
                "total_miner_reward": "304280060856",
                "fee_recipient_eth_diff": "304280060856"
            },
            {
                "transaction_hash": "0xd441a44e2adf57f0d53e027d4441cdfee8653cd7f259ec0c90b60ea144b31d32",
                "tx_index": 0,
                "bundle_index": 20,
                "block_number": 18975317,
                "eao_address": "0x758aC3DC8FB6F939adf42bB83e717f94619052f5",
                "to_address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
                "gas_used": 118712,
                "gas_price": "11300000",
                "coinbase_transfer": "0",
                "eth_sent_to_fee_recipient": "0",
                "total_miner_reward": "1341445600000",
                "fee_recipient_eth_diff": "1341445600000"
            },
            {
                "transaction_hash": "0x02cbeb153f91225abcdad3cd4d39d457b5e13f3fb1191f26c73c328c50f54071",
                "tx_index": 0,
                "bundle_index": 19,
                "block_number": 18975317,
                "eao_address": "0x4a25D28d10B02BCF13a16068F56d167D8F96d093",
                "to_address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
                "gas_used": 181502,
                "gas_price": "12500000",
                "coinbase_transfer": "0",
                "eth_sent_to_fee_recipient": "0",
                "total_miner_reward": "2268775000000",
                "fee_recipient_eth_diff": "2268775000000"
            },
            {
                "transaction_hash": "0x2b89ed3dbfe8946229468f33e31ed447631c192906344b7c62b6e927a7a5a512",
                "tx_index": 12,
                "bundle_index": 18,
                "block_number": 18975317,
                "eao_address": "0x4960DC043DDc244A02192898B3e2F1730194F0ac",
                "to_address": "0xf2B2420CEff184EEc76B3de15bd90C5734e45449",
                "gas_used": 21000,
                "gas_price": "10000001",
                "coinbase_transfer": "0",
                "eth_sent_to_fee_recipient": "0",
                "total_miner_reward": "210000021000",
                "fee_recipient_eth_diff": "210000021000"
            }
        ],
        "latest_block_number": 18975317
    }
}
```

***

**3. API URL**: [`https://api.expand.network/chain/getflashbotbundle`](https://docs.expand.network/integrations/blockchains/evm-based-blockchains/ethereum#getflashbotbundle)

**Sample Request:**

```url
https://api.expand.network/chain/getflashbotbundle?bundleHash=0x2228f5d8954ce31dc1601a8ba264dbd401bf1428388ce88238932815c5d6f23f
```

**Sample Response:**&#x20;

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "transactions": [
            {
                "transaction_hash": "0xd9cdf1483a85aa206625c66fea49059b96ffae1c086f76664cfa3f91a495d73a",
                "tx_index": 0,
                "bundle_index": 3,
                "block_number": 9091437,
                "eao_address": "0x8D460B72eaF3d63830E16C22d1Fc6908D0834Abe",
                "to_address": "0x8D460B72eaF3d63830E16C22d1Fc6908D0834Abe",
                "gas_used": 21000,
                "gas_price": "1000000000",
                "coinbase_transfer": "0",
                "eth_sent_to_fee_recipient": "0",
                "total_miner_reward": "21000000000000",
                "fee_recipient_eth_diff": "21000000000000"
            }
        ]
    }
}
```
