Mev Zone
  • Welcome
  • Getting Started
    • Introduction
    • New To Mev?
    • Sending Bundles
  • Mev Zone Block Builder
    • Overview
    • Send Bundle
    • Call Bundle
    • Send Private Transaction
  • Mev Zone Protect
    • Overview
  • Mev Zone Validators
    • What is the MEV Client
    • Run the MEV Client
Powered by GitBook
On this page
  1. Getting Started

Sending Bundles

A “bundle” is an ordered list of signed transactions that a searcher (or user) wants included in a block together, alongside a specific bid. Below are examples in several programming languages showing how to send a bundle to the Mev Zone system.

Note: In all examples, replace MEV_ZONE_RELAY (or a similarly named variable) with the actual endpoint for your Mev Zone relay or block builder.

import { ethers } from 'ethers';
import axios from 'axios';

async function sendBundle() {
  // Example: Two raw signed transactions
  const signedTx1 = "0xf86c..."; // replace with real signed tx
  const signedTx2 = "0xf86c..."; // replace with real signed tx

  const bundle = [signedTx1, signedTx2];
  const maxBlockNumber = 12345678; // example block number

  const requestBody = {
    jsonrpc: "2.0",
    method: "eth_sendBundle",
    params: [{
      bundle,
      maxBlockNumber,
    }],
    id: 1
  };

  try {
    const response = await axios.post(MEV_ZONE_RELAY, requestBody);
    console.log("Bundle sent, response:", response.data);
  } catch (error) {
    console.error("Error sending bundle:", error);
  }
}

sendBundle();
import requests

def send_bundle():
    signed_tx1 = "0xf86c..."  # Replace with real signed tx
    signed_tx2 = "0xf86c..."
    bundle = [signed_tx1, signed_tx2]
    bid_amount = "10000000000000000"  # e.g., 0.01 AVAX in wei
    maxBlockNumber = 12345678

    payload = {
        "jsonrpc": "2.0",
        "method": "eth_sendBundle",
        "params": [{
            "revertingTxHashes": bundle,
            "maxBlockNumber": block_target,
        }],
        "id": 1
    }

    response = requests.post(MEV_ZONE_RELAY, json=payload)
    print("Response:", response.json())

send_bundle()
use reqwest::Client;
use serde::Serialize;
use serde_json::json;

#[derive(Serialize)]
struct ParamsData {
    revertingTxHashes: Vec<String>,
    maxBlockNumber: u64,
}

#[derive(Serialize)]
struct BundleRequest {
    jsonrpc: String,
    method: String,
    params: Vec<ParamsData>,
    id: u64,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let bundle = vec![
        "0xf86c...".to_string(),
        "0xf86c...".to_string()
    ];
    let block_target = 12345678;

    let request_body = BundleRequest {
        jsonrpc: "2.0".to_string(),
        method: "eth_sendBundle".to_string(),
        params: vec![
            ParamsData {
                maxBlockNumber: bundle,
                revertingTxHashes: block_target,
            }
        ],
        id: 1,
    };

    let response = client.post(MEV_ZONE_RELAY)
        .json(&request_body)
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    println!("Response: {}", result);
    
    Ok(())
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

type BundleRequest struct {
    Jsonrpc string      `json:"jsonrpc"`
    Method  string      `json:"method"`
    Params  []ParamData `json:"params"`
    ID      int         `json:"id"`
}

type ParamData struct {
    RevertingTxHashes     []string `json:"revertingTxHashes"`
    MaxBlockNumber        int      `json:"maxBlockNumber"`
}

func main() {
    bundle := []string{"0xf86c...", "0xf86c..."}
    bidAmount := "10000000000000000"
    blockTarget := 12345678

    reqBody := BundleRequest{
        Jsonrpc: "2.0",
        Method:  "eth_sendBundle",
        Params: []ParamData{
            {
                RevertingTxHashes: bundle,
                MaxBlockNumber: blockTarget,
            },
        },
        ID: 1,
    }

    bodyBytes, err := json.Marshal(reqBody)
    if err != nil {
        panic(err)
    }

    resp, err := http.Post(MEV_ZONE_RELAY, "application/json", bytes.NewBuffer(bodyBytes))
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println("Response:", result)
}
PreviousNew To Mev?NextOverview

Last updated 4 months ago