Passer au contenu
Média 1 pour l'article Web3Toolkit — Unity Web3 Toolkit (Local, Testnets & Mainnets)

Description

Web3Toolkit is a lightweight, Nethereum-based Unity toolkit that lets you wire up Web3 basics in minutes—connect with a developer key, run personal_sign, read native balance, and send the chain’s native coin—on Local/Hardhat, testnets (Sepolia, Base Sepolia, Polygon Amoy), and mainnets (Ethereum, Base, Polygon). It ships with a plug-and-play HUD prefab, a demo scene, IL2CPP-safe link.xml, and Editor menus to streamline setup. No SaaS—you control RPCs and keys.

Networks
  • Local: Hardhat (31337)

  • Testnets: Sepolia (11155111), Base Sepolia (84532), Polygon Amoy (80002)

  • Mainnets: Ethereum (1), Base (8453), Polygon (137)

What’s Included
  • Full C# runtime under AnvilInteractiveSolutions.Web3Toolkit

  • Demo scene Web3Toolkit_Demo.unity (lighting data included)

  • Web3ToolkitHUD.prefab (drop-in UI)

  • Runtime: IWallet, WalletController, DevWallet, BalanceService, NetSelect, Web3Rpc, NetExplorer, NetFaucet, Chains

  • Editor: Docs & setup menus (Open Docs, Install/Launch NuGet, Enable/Disable Toolkit)

  • Web3Toolkit.asmdef + link.xml

  • Extras: NuGetForUnity.4.5.0.unitypackage (bundled helper)

  • Docs: README.md, full PDF manual, CHANGELOG.md, LICENSE, ThirdPartyNotices.txt

Key Features
  • Inspector Network dropdown: Local / Sepolia / Base Sepolia / Amoy / Ethereum / Base / Polygon

  • Dev-key connect, personal_sign, native balance, send native coin

  • Explorer links (Etherscan/Basescan/Polygonscan) & Faucet helper for testnets

  • Optional gas estimate before sending

  • IL2CPP-ready (link.xml), assembly-def structured, single namespace

  • Clean interfaces; easy to extend with ERC-20/721 using Nethereum

Requirements & Project Settings
  • Unity 2021.3+

  • Player → Other Settings: API Compatibility = .NET Standard 2.1, Managed Stripping = Low

  • Android: Internet Access = Require

  • Exactly one Newtonsoft.Json (either Unity’s package or NuGet—do not keep both)

Installation (first import, zero errors)
  1. Tools → Web3Toolkit → Dependencies → Install NuGetForUnity (imports the bundled unitypackage; editor reloads).

  2. Tools → Web3Toolkit → Dependencies → Open NuGet Manager → install Nethereum.Web3.

  3. Tools → Web3Toolkit → Setup → Enable Web3Toolkit (after installing Nethereum).

  4. Open Assets/AnvilInteractiveSolutions/Web3Toolkit/Demo/Web3Toolkit_Demo.unity.

Quick Verification (Sepolia)
  1. In the demo UI, set Network = Sepolia.

  2. Paste a faucet-funded test private key → Connect (address & balance appear).

  3. Sign → Console logs sig=0x… and match=True.

  4. Enter To Address + Amount (e.g., 0.001) → Send → explorer opens with the tx hash.

Use Cases
  • Wallet login via signed message (server verifies personal_sign)

  • QA/dev flows with dev keys on Local/testnets

  • Native-coin micro-payments on L2 (Base/Polygon)

  • Token-gating & passes (extend with ERC-20/721 via Nethereum)

What’s Not Included (v1.0)
  • WalletConnect or custodial wallet adapters (roadmap)

  • Token/NFT UI in the shipped demo (intentionally focused on wallet + native coin)

Security Notes
  • Never ship real private keys in consumer builds—use throwaway/test keys.

  • Include nonce & short expiry in signed messages to avoid replay.

  • Keep only one Newtonsoft.Json.

Formats inclus