Arbitrum One
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Arbitrum One
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Nethereum is the primary .NET library for talking to Arbitrum One. Because Arbitrum One is a Nitro-based Optimistic Rollup that exposes the standard Ethereum JSON-RPC interface, Nethereum works against it unchanged — you simply point it at https://arbitrum.therpc.io/YOUR_API_KEY. The library targets .NET Standard 2.0+, so the same code runs across Unity3D games, Xamarin mobile apps, ASP.NET Core services, and Blazor front ends. Add it to your project with dotnet add package Nethereum.Web3.
Nethereum builds on .NET Standard 2.0+, which makes it portable across Unity3D, Xamarin, ASP.NET Core, and Blazor — useful when an Arbitrum One dApp shares wallet logic between a desktop service and a mobile or in-game client. Install it from NuGet with dotnet add package Nethereum.Web3.
Create a single new Web3("https://arbitrum.therpc.io/YOUR_API_KEY") instance and reuse it across your service. Every network-bound call — GetBalance, GetEtherTransferService, contract reads and writes — returns an async Task, so always await it. Avoid blocking on .Result or .Wait(): on Arbitrum One, where the sequencer returns soft confirmations in well under a second, the temptation to block is real, but doing so risks deadlocks in ASP.NET and Unity contexts. Keep the call chain async end to end.
To work with a deployed contract — say a GMX or Camelot pool on Arbitrum One — get a handle with _web3.Eth.GetContract(abi, contractAddress). From there, GetFunction(name) gives you a typed function you can either read with CallAsync<T>() (no gas, no state change) or write with SendTransactionAsync(). Reads resolve against the latest sequencer state almost instantly; writes are L2 transactions whose fee combines L2 execution cost with the L1 calldata posting cost, both paid in ETH.
In an ASP.NET Core API, register EthereumService as a singleton in Program.cs (or Startup.ConfigureServices) so the single Web3 instance pointed at Arbitrum One is shared across requests, then resolve it through constructor injection in your controllers. Wrap each await in a try/catch and return BadRequest(ex.Message) on failure — RPC errors, a malformed address, or a rejected transaction should surface as a clean 400 rather than an unhandled 500.
To watch contract events on Arbitrum One — a Swap from a Uniswap pool or a Transfer from an ERC-20 — define an event DTO and use _web3.Eth.GetEvent<YourEventDTO>(contractAddress) together with CreateFilterInput() to build a filter, then poll for changes. The block explorer at https://arbiscan.io is handy for confirming the event signatures and topics you expect before wiring up the subscription.
In Unity3D, initialize Web3 once in Awake() or Start() with the Arbitrum One endpoint so a blockchain-backed game can read balances and submit transactions without per-frame setup cost. Be careful with async void: it is acceptable only for the top-level Start() entry point. Push the real work into Task-returning helpers like InitializeWalletAsync and await them, so exceptions are caught and logged through Debug.LogError rather than silently lost. Arbitrum One's sub-second sequencer confirmations keep these awaits short enough to feel responsive in-game.