Skip to content

eth_sendPrivateTransaction support (MEV-Share private txs) #40

@koko1123

Description

@koko1123

Motivation

MEV-Share's eth_sendPrivateTransaction is distinct from a bundle — it submits a single private transaction with configurable hints about what information to share with searchers. It is the primary method users and protocols use to get MEV protection while still allowing searchers to backrun.

The existing flashbots.zig covers eth_sendBundle and mev_sendBundle but not eth_sendPrivateTransaction.

API

Addition to flashbots.zig:

/// Options for eth_sendPrivateTransaction (MEV-Share).
pub const SendPrivateTxOpts = struct {
    /// Raw signed transaction bytes.
    tx: []const u8,
    /// Maximum block number for inclusion. Null = current + 25.
    max_block_number: ?u64 = null,
    /// MEV-Share hint preferences — what to reveal to searchers.
    preferences: ?TxPreferences = null,

    pub const TxPreferences = struct {
        /// Reveal calldata to searchers.
        calldata: bool = false,
        /// Reveal contract address to searchers.
        contract_address: bool = false,
        /// Reveal event logs to searchers.
        logs: bool = false,
        /// Reveal 4-byte function selector to searchers.
        function_selector: bool = false,
        /// Which builders to share with. Null = all Flashbots builders.
        builders: ?[]const []const u8 = null,
    };
};

pub const SendPrivateTxResult = struct {
    tx_hash: [32]u8,
};

// New method on FlashbotsClient:
pub fn sendPrivateTransaction(
    self: *FlashbotsClient,
    allocator: std.mem.Allocator,
    opts: SendPrivateTxOpts,
) !SendPrivateTxResult

Wire format

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_sendPrivateTransaction",
  "params": [{
    "tx": "0x...",
    "maxBlockNumber": "0x...",
    "preferences": {
      "fast": false,
      "privacy": {
        "hints": ["calldata", "logs", "function_selector"],
        "builders": ["default"]
      }
    }
  }]
}

Auth via X-Flashbots-Signature (same as eth_sendBundle).

Relationship

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions