Nethereum.EngineApi.Hosting 7.1.0

Prefix Reserved
dotnet add package Nethereum.EngineApi.Hosting --version 7.1.0
                    
NuGet\Install-Package Nethereum.EngineApi.Hosting -Version 7.1.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.EngineApi.Hosting" Version="7.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nethereum.EngineApi.Hosting" Version="7.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Nethereum.EngineApi.Hosting" />
                    
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.EngineApi.Hosting --version 7.1.0
                    
#r "nuget: Nethereum.EngineApi.Hosting, 7.1.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.EngineApi.Hosting@7.1.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.EngineApi.Hosting&version=7.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Nethereum.EngineApi.Hosting&version=7.1.0
                    
Install as a Cake Tool

Nethereum.EngineApi.Hosting

Serve the Ethereum Engine API (newPayload, forkchoiceUpdated, getPayload) over the JWT-authenticated authrpc port, the interface a consensus client such as Lighthouse uses to drive an execution client.

It hosts an IEngineApiService that you supply, so the same endpoint fronts the DevChain block producer and the mainnet follower.

services.AddEngineApiServer(
    new EngineApiServerConfig { Port = 8551, JwtSecretPath = "./jwt.hex" },
    provider => engineApiService);

app.MapEngineApiEndpoints();

AddEngineApiServer reads or creates the shared secret at JwtSecretPath (hex, 32 bytes). Requests on the Engine port must carry an HS256 Authorization: Bearer token whose iat is within 60 seconds. The public RPC port is never served Engine methods.

The host resolves the RpcContext from the service provider, so register the chain's RpcContext first.

Registration

public static IServiceCollection AddEngineApiServer(
    this IServiceCollection services,
    EngineApiServerConfig config,
    Func<IServiceProvider, IEngineApiService> engineFactory,
    bool verbose = false)

public static WebApplication MapEngineApiEndpoints(this WebApplication app)

AddEngineApiServer registers the EngineApiServerConfig, the IEngineApiService your factory returns, an EngineJwtValidator built from the secret file, and an EngineApiHost (the Engine handler registry, its RpcDispatcher and the validator). The WebApplicationBuilder overload does the same on builder.Services. verbose gives the Engine dispatcher a logger.

MapEngineApiEndpoints adds http://{BindAddress}:{Port} to the application's URLs and answers on that port only: a request without a valid token gets 401 {"error":"unauthorized"}, a non-POST request gets 404, and a POST body is dispatched to the Engine handlers. Requests on any other port pass through to the rest of the application.

EngineApiServerConfig:

Property Default
Port 8551 (EngineApiServerConfig.DefaultPort)
BindAddress "127.0.0.1"
JwtSecretPath "./jwt.hex" (EngineApiServerConfig.DefaultJwtSecretFileName)

The shared secret and the token

EngineJwtSecret.LoadOrCreate(path) loads the secret file consensus clients share. The file holds exactly 32 bytes as hex, optionally prefixed with 0x; an empty, short, non-hex or oversized file throws InvalidDataException, so an empty key can never validate a token. A missing file is created: the new secret is written to a temporary file and moved into place, and on Unix the file is readable and writable by its owner only.

EngineJwtValidator.TryValidate(authorizationHeaderValue, out error) accepts a Bearer token only when the header names the HS256 algorithm, the signature matches (compared in constant time), and the iat claim is present and within 60 seconds of the clock. A token whose header or claims are valid JSON of the wrong shape is refused with false, not an exception, so the caller answers 401.

Used by

  • Nethereum.DevChain: AddDevChainServer registers the Engine API when DevChainServerConfig.EngineApiEnabled is set, with the secret at <DataDir>/jwt.hex unless EngineJwtSecretPath names another.
  • Nethereum.MainnetChain: --engine (MainnetChain:Engine:Enabled) registers the follower's Engine service through MainnetEngineComposition.AddMainnetEngine, with --engine-port and --engine-jwt-secret.
Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Nethereum.EngineApi.Hosting:

Package Downloads
Nethereum.DevChain

Nethereum DevChain - Development chain RPC handlers for testing and development

Nethereum.MainnetChain

Nethereum MainnetChain - read-only mainnet follower + serving library: composes FollowerChainNode (CoreChain) + DevP2P sync orchestration + optional beacon LightClient consensus gate + eth_/net_/web3_ JSON-RPC. Hostable from a CLI, Aspire, or tests via AddMainnetChainServer / MapMainnetChainEndpoints.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.1.0 55 11/10/2026