Skip to main content

Web (Blazor) dApp Integration

Build Blazor web applications that connect to browser wallets, authenticate users with Sign-In with Ethereum (SIWE), and interact with smart contracts — all without leaving the .NET ecosystem.

Wallet Connection

EIP-6963 replaces the old window.ethereum injection model. All installed browser wallets announce themselves and users choose which to connect:

<EIP6963Wallet OnWalletConnected="HandleWalletConnected" />

MetaMask

Direct MetaMask integration for legacy support:

await MetamaskHostProvider.EnableProviderAsync();
var web3 = await MetamaskHostProvider.GetWeb3Async();

WalletConnect / Reown

Mobile wallet support via QR code scanning:

dotnet add package Nethereum.Reown.AppKit.Blazor

Authentication with SIWE

Integrate Ethereum wallet authentication with Blazor's built-in <AuthorizeView>:

<AuthorizeView Roles="SiweAuthenticated">
<Authorized>
<p>Connected as @context.User.Identity?.Name</p>
</Authorized>
</AuthorizeView>

The EthereumAuthenticationStateProvider manages wallet connection state, while SiweAuthenticationServerStateProvider and SiweAuthenticationWasmStateProvider add full SIWE authentication with JWT tokens and session management.

A complete starter template is available: Nethereum.Templates.Siwe — includes REST API + Blazor Server + Blazor WASM with MetaMask signing, JWT creation, and role-based access.

Smart Contract Interaction

Nethereum.Blazor provides dynamic contract interaction UI — call any contract function by providing an ABI, without code generation:

// Dynamic contract interaction via Blazor components
// Supports read/write functions, event querying, and ABI-decoded results

Packages

PackageDescription
Nethereum.BlazorEIP-6963 wallet discovery, auth state provider, dynamic contract interaction UI
Nethereum.EIP6963WalletInteropEIP-6963 JavaScript interop core
Nethereum.MetamaskMetaMask wallet provider abstractions
Nethereum.Metamask.BlazorMetaMask Blazor interop component
Nethereum.WalletConnectWalletConnect v2 protocol implementation
Nethereum.Reown.AppKit.BlazorReown AppKit modal (WalletConnect UI) for Blazor
Nethereum.Blazor.SolidityIn-browser Solidity step-through debugger

SIWE packages (Nethereum.Siwe, Nethereum.Siwe.Core) are in the Protocols section. The authentication guide in this section shows how to use them with Blazor.