DevChain Template
The nethereum-devchain template gives you a complete local Ethereum development environment — a JSON-RPC node, a blockchain indexer, a Blazor explorer, and a PostgreSQL database — all orchestrated by .NET Aspire. It's the simplest way to get a local chain running for development and testing.
What You'll Build
By the end of this guide, you'll have four services running together:
- DevChain — an in-memory Ethereum node with EIP-1559, debug tracing, and pre-funded accounts
- Indexer — a background worker that indexes blocks, transactions, token transfers, and MUD records into PostgreSQL
- Explorer — a full Blazor blockchain explorer with contract interaction, ABI decoding, and wallet connection
- PostgreSQL — a managed database container for all indexed data
Prerequisites
- .NET 10 SDK or later
- Docker Desktop (for PostgreSQL)
Step 1: Install the Template Pack
dotnet new install Nethereum.Aspire.TemplatePack
This installs both the nethereum-devchain and nethereum-dapp templates. You only need to run this once.
Step 2: Create the Project
dotnet new nethereum-devchain -n MyChain
cd MyChain
This creates a solution with four projects:
MyChain/
├── AppHost/ Aspire orchestrator — wires everything together
├── DevChain/ Ethereum node
├── Indexer/ Block/transaction indexer
├── Explorer/ Blazor blockchain explorer
└── ServiceDefaults/ Shared Aspire configuration (health checks, telemetry)
You can customise the chain ID or package versions at creation time:
dotnet new nethereum-devchain -n MyChain --ChainId 42069 --NethereumVersion 6.0.4
Step 3: Set the Dev Account Private Key
The Explorer uses a pre-funded account for contract deployment and interaction. Set it via user secrets:
cd AppHost
dotnet user-secrets set "Parameters:devAccountPrivateKey" "5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
cd ..
This is the default Hardhat/Foundry account #2 with 10,000 ETH. Use any funded account you prefer.
Step 4: Run the Solution
dotnet run --project AppHost
The Aspire dashboard opens automatically (typically at https://localhost:17178). You'll see all four services starting up with health indicators.
Step 5: Explore the Dashboard
From the Aspire dashboard you can:
- View service health — green means healthy, click for details
- Read logs — each service's console output in real-time
- Trace requests — distributed traces across DevChain → Indexer → Explorer
- Click through to endpoints — the Explorer and DevChain URLs are clickable
Click the Explorer endpoint to open the blockchain explorer. You'll see the genesis block and any transactions generated by the system.
Step 6: Interact with the DevChain
The DevChain exposes a standard JSON-RPC endpoint. Connect any Ethereum tool to the URL shown in the Aspire dashboard.
With Nethereum:
var web3 = new Web3("http://localhost:<port>");
var balance = await web3.Eth.GetBalance.SendRequestAsync("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266");
With Foundry:
cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://localhost:<port>
With curl:
curl -X POST http://localhost:<port> \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
Replace <port> with the actual port from the Aspire dashboard.
Configuration
DevChain Storage
By default, the DevChain persists state to SQLite so your chain survives restarts. For ephemeral testing:
{
"DevChain": {
"Storage": "memory",
"ChainId": 31337,
"AutoMine": true
}
}
Explorer Options
The Explorer connects to DevChain and PostgreSQL automatically via Aspire service discovery. The AppHost also configures a dev account for contract interaction and enables pending transaction display:
var explorer = builder.AddProject<Projects.Explorer>("explorer")
.WithReference(postgres)
.WithReference(devchain)
.WaitFor(indexer)
.WithEnvironment("Explorer__DevAccountPrivateKey", devAccountKey)
.WithEnvironment("Explorer__EnablePendingTransactions", "true");
Next Steps
Now that you have a running DevChain environment, you're ready to build on top of it:
- dApp Template — Add a WebApp, Solidity contracts, and wallet integration to create a full-stack dApp
- DevChain Quickstart — Learn more about the DevChain library itself — configuration, storage modes, RPC methods, and forking