Nethereum.JsonRpc.IpcClient 5.8.0

Prefix Reserved
dotnet add package Nethereum.JsonRpc.IpcClient --version 5.8.0
                    
NuGet\Install-Package Nethereum.JsonRpc.IpcClient -Version 5.8.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nethereum.JsonRpc.IpcClient" Version="5.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nethereum.JsonRpc.IpcClient" Version="5.8.0" />
                    
Directory.Packages.props
<PackageReference Include="Nethereum.JsonRpc.IpcClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nethereum.JsonRpc.IpcClient --version 5.8.0
                    
#r "nuget: Nethereum.JsonRpc.IpcClient, 5.8.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nethereum.JsonRpc.IpcClient@5.8.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nethereum.JsonRpc.IpcClient&version=5.8.0
                    
Install as a Cake Addin
#tool nuget:?package=Nethereum.JsonRpc.IpcClient&version=5.8.0
                    
Install as a Cake Tool

Nethereum.JsonRpc.IpcClient

High-performance IPC (Inter-Process Communication) JSON-RPC client for local Ethereum node communication.

Overview

Nethereum.JsonRpc.IpcClient provides IPC transport implementations for communicating with local Ethereum nodes via Named Pipes (Windows) and Unix Domain Sockets (Linux/macOS). IPC offers significantly lower latency than HTTP for local node communication, making it ideal for high-performance applications running on the same machine as the Ethereum node.

Key Features:

  • Named Pipes support (Windows)
  • Unix Domain Sockets support (Linux, macOS)
  • Ultra-low latency (~1ms vs ~5ms HTTP)
  • Automatic connection management and retry
  • Thread-safe request handling
  • Production-tested reliability
  • Compatible with Geth, Erigon, Besu IPC endpoints

Use Cases:

  • Local node communication (same machine)
  • High-frequency trading / MEV bots
  • Low-latency blockchain indexers
  • Real-time event processing
  • Production node operators
  • Development and testing with local nodes

Installation

dotnet add package Nethereum.JsonRpc.IpcClient

Platform Support:

  • Windows: Named Pipes (IpcClient)
  • Linux/macOS: Unix Domain Sockets (UnixIpcClient)

Dependencies

Nethereum:

  • Nethereum.JsonRpc.Client - Core RPC abstraction (provides JSON serialization and logging support)

External:

  • System.IO.Pipes (v4.3.0) - Named pipes support

Quick Start

Windows (Named Pipes)

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;

// Connect to Geth IPC endpoint (Windows)
var client = new IpcClient(@"\\.\pipe\geth.ipc");

// Query blockchain with ultra-low latency
var ethBlockNumber = new EthBlockNumber(client);
var blockNumber = await ethBlockNumber.SendRequestAsync();

Console.WriteLine($"Current block: {blockNumber.Value}");
// Typical latency: ~1ms (vs ~5ms for HTTP localhost)

Linux/macOS (Unix Domain Sockets)

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;

// Connect to Geth IPC endpoint (Linux/macOS)
var client = new UnixIpcClient("/home/user/.ethereum/geth.ipc");

// Query blockchain
var ethChainId = new EthChainId(client);
var chainId = await ethChainId.SendRequestAsync();

Console.WriteLine($"Chain ID: {chainId.Value}");

Usage Examples

Example 1: Connecting to Geth IPC Endpoints

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;
using System.Runtime.InteropServices;

// Platform-specific IPC path detection
IClient client;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
    // Windows: Named pipe
    client = new IpcClient(@"\\.\pipe\geth.ipc");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
    // Linux: Unix socket
    client = new UnixIpcClient("/home/user/.ethereum/geth.ipc");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
    // macOS: Unix socket
    client = new UnixIpcClient("/Users/user/Library/Ethereum/geth.ipc");
}
else
{
    throw new PlatformNotSupportedException();
}

// Use with RPC services
var ethBlockNumber = new EthBlockNumber(client);
var blockNumber = await ethBlockNumber.SendRequestAsync();

Console.WriteLine($"Block: {blockNumber.Value}");

Example 2: Custom Connection Timeout

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;

var client = new IpcClient(@"\\.\pipe\geth.ipc");

// Default timeout is 120 seconds
Console.WriteLine($"Default timeout: {client.ConnectionTimeout.TotalSeconds}s");

// Set custom timeout
client.ConnectionTimeout = TimeSpan.FromSeconds(10);

try
{
    var ethAccounts = new EthAccounts(client);
    var accounts = await ethAccounts.SendRequestAsync();
    Console.WriteLine($"Accounts: {string.Join(", ", accounts)}");
}
catch (RpcClientTimeoutException ex)
{
    Console.WriteLine($"IPC connection timed out: {ex.Message}");
}

Example 3: Logging with Microsoft.Extensions.Logging

using Nethereum.JsonRpc.IpcClient;
using Microsoft.Extensions.Logging;
using Nethereum.RPC.Eth;

// Create logger
var loggerFactory = LoggerFactory.Create(builder =>
{
    builder.AddConsole();
    builder.SetMinimumLevel(LogLevel.Debug);
});

var logger = loggerFactory.CreateLogger<IpcClient>();

// Create client with logging
var client = new UnixIpcClient(
    "/home/user/.ethereum/geth.ipc",
    jsonSerializerSettings: null,
    log: logger
);

// All requests are logged
var ethGasPrice = new EthGasPrice(client);
var gasPrice = await ethGasPrice.SendRequestAsync();
// Console output: Sending request: {"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}
// Console output: Received response: {"jsonrpc":"2.0","result":"0x...","id":1}

Example 4: Using with Nethereum.Web3

using Nethereum.Web3;
using Nethereum.JsonRpc.IpcClient;
using System.Runtime.InteropServices;

// Create IPC client
IClient ipcClient = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
    ? new IpcClient(@"\\.\pipe\geth.ipc")
    : new UnixIpcClient("/home/user/.ethereum/geth.ipc") as IClient;

// Use with Web3
var web3 = new Web3(ipcClient);

// Ultra-fast local queries
var balance = await web3.Eth.GetBalance.SendRequestAsync(
    "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
);

var blockNumber = await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();

Console.WriteLine($"Balance: {Web3.Convert.FromWei(balance)} ETH");
Console.WriteLine($"Block: {blockNumber.Value}");

Example 5: High-Frequency Request Pattern (MEV Bot)

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;
using System.Diagnostics;

var client = new UnixIpcClient("/home/user/.ethereum/geth.ipc");
client.ConnectionTimeout = TimeSpan.FromSeconds(5);

// High-frequency block monitoring with minimal latency
var ethBlockNumber = new EthBlockNumber(client);

var lastBlock = BigInteger.Zero;
while (true)
{
    var sw = Stopwatch.StartNew();
    var currentBlock = await ethBlockNumber.SendRequestAsync();
    sw.Stop();

    if (currentBlock.Value > lastBlock)
    {
        Console.WriteLine($"New block {currentBlock.Value} detected in {sw.ElapsedMilliseconds}ms");
        lastBlock = currentBlock.Value;

        // Execute time-sensitive logic here (MEV, arbitrage, etc.)
    }

    await Task.Delay(100); // Poll every 100ms
}
// Typical latency: 1-2ms (IPC) vs 5-10ms (HTTP localhost)

Example 6: Connection Error Handling and Retry

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;
using Polly;

var client = new IpcClient(@"\\.\pipe\geth.ipc");
client.ConnectionTimeout = TimeSpan.FromSeconds(10);

// Define retry policy for IPC connection failures
var retryPolicy = Policy
    .Handle<RpcClientTimeoutException>()
    .Or<RpcClientUnknownException>()
    .Or<IOException>()
    .WaitAndRetryAsync(
        retryCount: 3,
        sleepDurationProvider: attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),
        onRetry: (exception, timeSpan, retryCount, context) =>
        {
            Console.WriteLine($"IPC retry {retryCount} after {timeSpan.TotalSeconds}s: {exception.Message}");
        }
    );

try
{
    var blockNumber = await retryPolicy.ExecuteAsync(async () =>
    {
        var ethBlockNumber = new EthBlockNumber(client);
        return await ethBlockNumber.SendRequestAsync();
    });

    Console.WriteLine($"Success! Block: {blockNumber.Value}");
}
catch (RpcClientTimeoutException ex)
{
    Console.WriteLine($"IPC timeout after retries: {ex.Message}");
    Console.WriteLine("Is Geth running? Check IPC path.");
}
catch (RpcClientUnknownException ex)
{
    Console.WriteLine($"IPC connection error: {ex.Message}");
    Console.WriteLine($"IPC path: {client.IpcPath}");
}

Example 7: Erigon IPC Connection

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;

// Erigon default IPC paths
var client = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
    ? new IpcClient(@"\\.\pipe\erigon.ipc")
    : new UnixIpcClient("/home/user/.local/share/erigon/erigon.ipc") as IClient;

// Erigon-specific RPC methods work over IPC
var ethBlockNumber = new EthBlockNumber(client);
var blockNumber = await ethBlockNumber.SendRequestAsync();

Console.WriteLine($"Erigon block: {blockNumber.Value}");

Example 8: Custom JsonSerializerSettings

using Nethereum.JsonRpc.IpcClient;
using Newtonsoft.Json;
using Nethereum.RPC.Eth;

// Create custom serializer settings
var settings = new JsonSerializerSettings
{
    NullValueHandling = NullValueHandling.Ignore,
    Formatting = Formatting.None,
    DateTimeZoneHandling = DateTimeZoneHandling.Utc
};

// Create client with custom settings
var client = new IpcClient(
    @"\\.\pipe\geth.ipc",
    jsonSerializerSettings: settings
);

var ethChainId = new EthChainId(client);
var chainId = await ethChainId.SendRequestAsync();

Console.WriteLine($"Chain ID: {chainId.Value}");

Example 9: Proper Disposal Pattern

using Nethereum.JsonRpc.IpcClient;
using Nethereum.RPC.Eth;

// IpcClient implements IDisposable - always dispose properly
using (var client = new UnixIpcClient("/home/user/.ethereum/geth.ipc"))
{
    var ethBlockNumber = new EthBlockNumber(client);
    var blockNumber = await ethBlockNumber.SendRequestAsync();

    Console.WriteLine($"Block: {blockNumber.Value}");

    // Client automatically disposed and connection closed
}

// For long-running applications, reuse the client
var persistentClient = new IpcClient(@"\\.\pipe\geth.ipc");
try
{
    // Use throughout application lifetime
    while (true)
    {
        var ethBlockNumber = new EthBlockNumber(persistentClient);
        var block = await ethBlockNumber.SendRequestAsync();
        await Task.Delay(1000);
    }
}
finally
{
    persistentClient.Dispose();
}

API Reference

IpcClient (Windows - Named Pipes)

public class IpcClient : IpcClientBase, IDisposable
{
    public IpcClient(string ipcPath,
        JsonSerializerSettings jsonSerializerSettings = null,
        ILogger log = null)
}

Parameters:

  • ipcPath: Named pipe path (e.g., \\.\pipe\geth.ipc)
  • jsonSerializerSettings: Optional custom JSON settings
  • log: Optional logger instance

UnixIpcClient (Linux/macOS - Unix Domain Sockets)

public class UnixIpcClient : IpcClientBase, IDisposable
{
    public UnixIpcClient(string ipcPath,
        JsonSerializerSettings jsonSerializerSettings = null,
        ILogger log = null)
}

Parameters:

  • ipcPath: Unix socket path (e.g., /home/user/.ethereum/geth.ipc)
  • jsonSerializerSettings: Optional custom JSON settings
  • log: Optional logger instance

Properties

public TimeSpan ConnectionTimeout { get; set; } // Default: 120 seconds
public string IpcPath { get; }
public int ForceCompleteReadTotalMiliseconds { get; set; } // Default: 2000

Key Methods (Inherited from ClientBase)

public override Task<RpcResponseMessage> SendAsync(RpcRequestMessage request, string route = null)
public void Dispose()

Important Notes

Common IPC Paths

Geth: | Platform | Default IPC Path | |----------|------------------| | Windows | \\.\pipe\geth.ipc | | Linux | /home/user/.ethereum/geth.ipc | | macOS | /Users/user/Library/Ethereum/geth.ipc |

Erigon: | Platform | Default IPC Path | |----------|------------------| | Windows | \\.\pipe\erigon.ipc | | Linux | /home/user/.local/share/erigon/erigon.ipc | | macOS | /Users/user/Library/Erigon/erigon.ipc |

Besu: | Platform | Default IPC Path | |----------|------------------| | Windows | Not officially supported | | Linux | /tmp/besu.ipc | | macOS | /tmp/besu.ipc |

Performance Comparison

Transport Latency (localhost) Use Case
IPC 0.5-2ms Local node, high-frequency
HTTP 3-10ms Local node, standard
HTTPS (remote) 50-200ms Cloud providers

IPC is ~5x faster than HTTP for local communication.

Thread Safety

  • NOT thread-safe - uses internal locking for single connection
  • For concurrent requests, create multiple client instances
  • Each instance maintains its own IPC connection
  • Safe to use from single thread or with external synchronization

Batch Requests

IPC clients support batch requests via inherited SendBatchRequestAsync:

var batch = new RpcRequestResponseBatch();
batch.BatchItems.Add(new RpcRequestResponseBatchItem<string>(
    new RpcRequestMessage(1, "eth_blockNumber")
));
batch.BatchItems.Add(new RpcRequestResponseBatchItem<string>(
    new RpcRequestMessage(2, "eth_chainId")
));

var result = await client.SendBatchRequestAsync(batch);

However, IPC is already very fast - batching provides less benefit than with HTTP.

Error Handling

Exception Cause Solution
RpcClientTimeoutException Connection timeout Check node is running, verify IPC path
RpcClientUnknownException IPC communication error Verify IPC path, check permissions
IOException Pipe/socket error Restart node, check file system

Limitations

  • Single connection per client - use multiple instances for concurrency
  • No subscription support - use WebSocketClient for eth_subscribe
  • Local only - IPC cannot communicate with remote nodes
  • Platform-specific - Named Pipes (Windows) vs Unix Sockets (Linux/macOS)

When to Use IPC vs HTTP vs WebSocket

Use IPC when:

  • Running on same machine as node
  • Ultra-low latency required (<2ms)
  • High-frequency requests (MEV, indexing)
  • Production node operator

Use HTTP when:

  • Connecting to remote node
  • Simple request/response pattern
  • Standard latency acceptable (5-10ms)

Use WebSocket when:

  • Need real-time subscriptions (eth_subscribe)
  • Event streaming required
  • Push notifications from node

Alternative Transports

  • Nethereum.JsonRpc.RpcClient - HTTP/HTTPS transport
  • Nethereum.JsonRpc.WebSocketClient - WebSocket transport (subscriptions)
  • Nethereum.JsonRpc.SystemTextJsonRpcClient - HTTP with System.Text.Json

Core Dependencies

  • Nethereum.JsonRpc.Client - Abstraction layer

Higher-Level APIs

  • Nethereum.Web3 - Complete Web3 API

Starting Geth/Erigon with IPC

Geth

# Linux/macOS
geth --ipcpath /home/user/.ethereum/geth.ipc

# Windows
geth --ipcpath \\.\pipe\geth.ipc

# Default IPC is enabled automatically
geth --http --http.api eth,net,web3

Erigon

# Linux
erigon --private.api.addr /home/user/.local/share/erigon/erigon.ipc

# Default IPC is enabled
erigon

Additional Resources

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Nethereum.JsonRpc.IpcClient:

Repository Stars
ChainSafe/web3.unity
🕹 Unity SDK for building games that interact with blockchains.
Version Downloads Last Updated
5.8.0 0 1/6/2026
5.0.0 581 5/28/2025
4.29.0 2,391 2/10/2025
4.28.0 272 1/7/2025
4.27.1 201 12/24/2024
4.27.0 202 12/24/2024
4.26.0 428 10/1/2024
4.25.0 259 9/19/2024
4.21.4 294 8/9/2024
4.21.3 224 7/22/2024
4.21.2 2,874 6/26/2024
4.21.1 260 6/26/2024
4.21.0 821 6/18/2024
4.20.0 311 3/28/2024
4.19.0 327 2/16/2024
4.18.0 2,113 11/21/2023
4.17.1 813 9/28/2023
4.17.0 239 9/27/2023
4.16.0 2,126 8/14/2023
4.15.2 2,721 7/11/2023
4.15.1 297 7/11/2023
4.15.0 294 7/11/2023
4.14.0 1,520 3/19/2023
4.13.0 480 2/18/2023
4.12.0 26,247 12/9/2022
4.11.0 1,411 10/27/2022
4.9.0 2,398 9/27/2022
4.8.0 4,729 8/24/2022
4.7.0 2,234 7/20/2022
4.6.1 1,456 6/18/2022
4.6.0 737 6/16/2022
4.5.0 1,413 5/13/2022
4.4.1 696 4/27/2022
4.4.0 766 4/27/2022
4.3.0 1,096 4/12/2022
4.2.0 1,939 2/18/2022
4.1.1 5,882 11/4/2021
4.1.0 718 10/15/2021
4.0.5 1,698 8/12/2021
4.0.4 646 8/10/2021
4.0.3 620 8/8/2021
4.0.2 677 8/5/2021
4.0.1 739 7/28/2021
4.0.0 763 7/26/2021
3.8.0 10,591 7/3/2020
3.7.1 2,189 2/13/2020
3.7.0 788 2/13/2020
3.6.0 860 1/27/2020
3.5.0 968 12/31/2019
3.4.0 1,378 7/29/2019
3.3.0 15,348 4/23/2019
3.2.0 6,234 4/8/2019
3.1.2 1,030 3/13/2019
3.1.1 921 3/12/2019
3.1.0 925 3/12/2019
3.0.0 2,418 11/28/2018
3.0.0-rc3 868 10/25/2018
3.0.0-rc2 810 10/24/2018
3.0.0-rc1 1,147 7/25/2018
2.5.1 1,710 6/5/2018
2.5.0 1,344 6/4/2018
2.4.0 1,772 3/11/2018
2.3.1 1,579 3/7/2018
2.3.0 1,349 3/6/2018
2.2.3 1,866 12/16/2017
2.2.2 1,674 12/16/2017
2.2.0 1,641 12/8/2017
2.1.0 1,554 10/23/2017
2.0.1 1,390 10/4/2017
2.0.0 1,380 9/26/2017
2.0.0-rc7 1,170 8/17/2017
2.0.0-rc6-2 1,231 7/29/2017
2.0.0-rc6.1 925 7/26/2017
2.0.0-rc5 1,175 6/19/2017
2.0.0-rc4 1,189 6/6/2017
2.0.0-rc3 1,162 4/11/2017
2.0.0-rc2-fix 1,176 4/6/2017
2.0.0-rc2 1,203 4/5/2017
1.0.6 1,826 2/3/2017
1.0.5 1,636 1/31/2017
1.0.4 1,851 12/10/2016
1.0.3 1,752 11/28/2016
1.0.2 1,728 11/21/2016
1.0.1 2,275 10/31/2016
1.0.0 2,115 9/14/2016
1.0.0-rc6 1,570 9/12/2016
1.0.0-rc5 2,137 8/1/2016
1.0.0-rc4 2,365 7/29/2016
1.0.0-rc1 1,912 3/30/2016