Nethereum.Unity.Metamask
NuGet:
Nethereum.Unity.Metamask| Source:src/Nethereum.Unity.Metamask/
Nethereum.Unity.Metamask
MetaMask integration for Unity WebGL builds. Provides JavaScript interop to connect MetaMask in the browser, sign transactions, and send RPC requests through MetaMask's provider — all within Unity's coroutine execution model.
Key Components
| Class | Purpose |
|---|---|
MetamaskWebglHostProvider | Unity IEthereumHostProvider implementation that delegates to MetaMask via JS interop |
MetamaskWebglInterop | Low-level JavaScript interop calls to window.ethereum |
MetamaskWebglCoroutineRequestRpcClient | Unity coroutine-based RPC client routing requests through MetaMask |
MetamaskTransactionCoroutineUnityRequest | Coroutine wrapper for sending transactions via MetaMask |
MetamaskRpcRequestMessage | RPC request message model |
Usage
// In a MonoBehaviour
var metamaskProvider = new MetamaskWebglHostProvider();
await metamaskProvider.EnableProviderAsync();
var web3 = await metamaskProvider.GetWeb3Async();
// Send a transaction
var transactionHash = await web3.Eth.GetEtherTransferService()
.TransferEtherAsync(toAddress, 0.1m);
Relationship to Other Packages
- Nethereum.Unity — Core Unity integration
- Nethereum.Unity.EIP6963 — Alternative: multi-wallet discovery via EIP-6963 (supports MetaMask and other wallets)
- Nethereum.Metamask — MetaMask abstractions (non-Unity, Blazor-focused)