Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
November 15, 2023 16:57
November 15, 2023 16:57
November 15, 2023 16:57
May 17, 2021 13:02
August 19, 2022 10:30
May 17, 2021 13:02
March 22, 2023 09:51


Use MetaMask with Blazor WebAssembly

This library provides an easy helper to use MetaMask with Blazor WebAssembly.

Live Demo

Real world implementation, login with MetaMask: SkyDocs

How to use

See included Blazor sample app.

Install: MetaMask.Blazor on NuGet

Register in Program.cs:


Inject the MetaMaskService in your Razor page

@using MetaMask.Blazor
@inject IMetaMaskService MetaMaskService

or class when using a .razor.cs file:

public IMetaMaskService MetaMaskService { get; set; } = default!;

Use the MetaMaskService:

Check if the user has MetaMask installed:

bool hasMetaMask = await MetaMaskService.HasMetaMask();

Check if the user has previously connected to your site.

bool isSiteConnected = await MetaMaskService.IsSiteConnected();

Initialize a new connection with MetaMask

    await MetaMaskService.ConnectMetaMask();
catch (UserDeniedException)
   //Handle "User Denied" case;

This can throw exceptions if the user decides to not allow the connection.

Once there is a connection, you can use other method calls like:

  • GetSelectedAddress
  • GetTransactionCount
  • SignTypedData
  • SendTransaction
  • or use the generic RPC method: GenericRpc


Listen to events: await MetaMaskService.ListenToEvents();

You can subscribe to two events:

  • IMetaMaskService.AccountChangedEvent
  • IMetaMaskService.NetworkChangedEvent



Development of MetaMask.Blazor has been made possible with a grant from The Graph.