unity-quickstart

Integrate Ethereum blockchain functionality into Unity games using Nethereum and WebGL wallet providers.

2.3k|744|Updated Nov 23, 2015
One-click install
npx skills add https://github.com/Nethereum/Nethereum --skill unity-quickstart
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-quickstart
Source: https://github.com/Nethereum/Nethereum/tree/main/plugins/nethereum-skills/skills/unity-quickstart
Command: npx skills add https://github.com/Nethereum/Nethereum --skill unity-quickstart

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Connecting Unity games to Ethereum requires handling platform-specific constraints: WebGL builds cannot use standard HTTP clients or private keys, and wallet connections must go through browser interop. This Skill provides working C# patterns for querying blockchain data, sending transactions, and connecting wallets across Unity platforms.

Core Features & Use Cases

  • Async Web3 in Unity: Query block numbers, balances, and contract state using UnityWebRequestRpcTaskClient, which works in WebGL builds.
  • WebGL Wallet Connection: Connect MetaMask or any browser wallet via EIP-6963 multi-wallet discovery, with account and network change events.
  • ERC-20/ERC-721/ERC-1155 Support: Use built-in typed contract services to read token balances and metadata without ABI files or code generation.
  • Use Case: A game developer building an NFT-based game can connect the player's MetaMask wallet in a WebGL build, read their ERC-721 inventory, and display owned items in-game.

Quick Start

Use the unity-quickstart skill to connect a MetaMask wallet in my Unity WebGL game and display the player's ETH balance.

Frequently Asked Questions about unity-quickstart

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect MetaMask to a Unity WebGL game?

Use EIP6963WebglHostProvider to discover installed browser wallets, then call EnableProviderAsync to connect. For MetaMask specifically, MetamaskWebglHostProvider provides a direct fallback. Both return an IWeb3 instance where the wallet handles signing.

How to query ERC-20 token balances in Unity with Nethereum?

Use the built-in typed service web3.Eth.ERC20.GetContractService(tokenAddress), then call BalanceOfQueryAsync with the owner address. No ABI file or code generation is needed, and ERC-721 and ERC-1155 have equivalent services.

Does Nethereum work in Unity WebGL builds?

Yes, but WebGL requires UnityWebRequestRpcTaskClient for RPC calls instead of standard HTTP clients, plus the WebGLThreadingPatcher package for async/await support. Private keys cannot be used in WebGL; signing must go through a browser wallet.

Why does async/await not work in my Unity WebGL build?

Unity WebGL lacks threading support, so async continuations never resume by default. Install the WebGLThreadingPatcher package to enable async/await, and for IL2CPP builds set IL2CPP Code Generation to Faster (smaller) builds in Player Settings.

Can I use private keys to sign transactions in Unity?

Private key signing works on Windows, macOS, Linux, iOS, and Android using Nethereum.Web3.Accounts.Account with a chain ID. In WebGL builds it is not supported; use EIP-6963 or MetaMask wallet interop so the browser wallet signs transactions.