Nethereum is the primary .NET library for talking to Base, the Coinbase-built OP Stack rollup that settles to Ethereum L1. It targets .NET Standard 2.0+, so the same code reaches Base from Unity3D games, Xamarin mobile apps, ASP.NET Core services, and Blazor front-ends. Because Base is a fully EVM-equivalent chain with ETH as its gas token, every Nethereum call you already know from Ethereum works unchanged against https://base.therpc.io/YOUR_API_KEY. Install it with dotnet add package Nethereum.Web3.
Nethereum targets .NET Standard 2.0+ and is compatible with Unity3D, Xamarin, ASP.NET Core, and Blazor, so a single Base integration can serve a game client, a mobile wallet, and a backend API. Add it from NuGet with dotnet add package Nethereum.Web3.
Nethereum
Connect by passing your Base endpoint URL to new Web3("https://base.therpc.io/YOUR_API_KEY"). Every network method on Base is an async Task — GetBalance.SendRequestAsync, TransferEtherAsync, and the rest — so always await them. Avoid blocking on .Result or .Wait(), which can deadlock in ASP.NET and Unity synchronization contexts. With ~2s Base block times, awaited calls return quickly enough for responsive UIs.
using Nethereum.Web3;
using Nethereum.Web3.Accounts;
using Nethereum.Util;
using Nethereum.Hex.HexTypes;
public class EthereumService
{
private readonly Web3 _web3;
public EthereumService(string url)
{
_web3= new Web3(url);
}
public async Task<decimal> GetBalanceAsync(string address)
{
var balance = await _web3.Eth.GetBalance.SendRequestAsync(address);
return Web3.Convert.FromWei(balance.Value);
}
public async Task<string> SendTransactionAsync(
string privateKey,
string toAddress,
decimal etherAmount)
{
var account = new Account(privateKey);
var web3= new Web3(account, _web3.Client.Url);
var transaction = await web3.Eth.GetEtherTransferService()
Key features: full Base integration over standard EVM JSON-RPC, smart contract deployment and interaction, HD wallet support, Unity3D and Xamarin compatibility, and IPC/RPC/WebSocket transports
Smart Contract Integration
To work with a deployed contract on Base — say an Aerodrome pool or a Uniswap router — obtain a handle from _web3.Eth.GetContract(abi, contractAddress). Use GetFunction(name) then CallAsync<T>(...) for read-only views, which cost no gas, and SendTransactionAsync(...) for state-changing writes, which spend ETH for gas. You can verify the contract address and ABI on https://basescan.org before wiring it up.
public class SmartContractService
{
private readonly Web3 _web3;
private readonly Contract _contract;
public SmartContractService(string url, string contractAddress, string abi)
In ASP.NET Core, register EthereumService in the DI container in Program.cs (or Startup.cs) and let the framework inject it into your controllers, so the Base connection is configured once and reused. Wrap each awaited call in try/catch and return BadRequest(ex.Message) on failure — this keeps a dropped RPC request or an invalid Base address from throwing an unhandled 500.
public EthereumController(EthereumService ethereumService)
{
_ethereumService = ethereumService;
}
[HttpGet("balance/{address}")]
public async Task<ActionResult<decimal>> GetBalance(string address)
{
try
{
var balance = await _ethereumService.GetBalanceAsync(address);
return Ok(balance);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
Event Handling
To watch contract events on Base — for example ERC-20 Transfer logs or a DEX Swap event — define an event DTO and call _web3.Eth.GetEvent<TEventDTO>(contractAddress). Build a filter with CreateFilterInput() and poll with GetFilterChanges, or subscribe to the returned stream. Given Base's ~2s blocks, a short polling interval keeps your log feed close to real time.
public class EventMonitorService
{
private readonly Web3 _web3;
public async Task MonitorEventsAsync(string contractAddress, string eventName)
{
var filterAll = _web3.Eth.GetEvent<YourEventDTO>(contractAddress)
.CreateFilterInput();
var subscription = _web3.Eth.GetEvent<YourEventDTO>(contractAddress)
.GetFilterChanges(filterAll);
subscription.Subscribe(evt =>
{
Console.WriteLine($"New event: {evt.Event}");
});
}
}
Unity3D Integration
For Unity3D games on Base, initialize Web3 once in Start() or Awake() with your https://base.therpc.io/YOUR_API_KEY endpoint. async void is only safe on Unity lifecycle hooks like Start(); for everything else prefer async Task helpers and await them from those hooks, since an unhandled exception in async void cannot be caught and can crash the frame. Base's low fees and ETH gas make it a practical settlement layer for in-game assets and on-chain rewards.
public class EthereumUnityManager : MonoBehaviour
{
private Web3 _web3;
private async void Start()
{
_web3= new Web3("https://base.therpc.io/YOUR_API_KEY");
await InitializeWalletAsync();
}
private async Task InitializeWalletAsync()
{
try
{
var balance = await _web3.Eth.GetBalance.SendRequestAsync("YOUR_ADDRESS");