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.
web3.swift, maintained by Argent, is the primary Swift library for building Arbitrum One apps on Apple platforms, targeting iOS 13+ and macOS 10.15+. Because Arbitrum One is an EVM-equivalent Nitro rollup speaking standard Ethereum JSON-RPC, the library connects to https://arbitrum.therpc.io/YOUR_API_KEY with no chain-specific setup. Add it through Swift Package Manager using the repository at https://github.com/argentlabs/web3.swift.
web3.swift supports iOS 13+ and macOS 10.15+, so the same Arbitrum One client code runs in an iPhone wallet and a macOS companion app. Add it via Swift Package Manager by pointing Xcode at the argentlabs/web3.swift repository.
Instantiate the client with Web3(rpcURL: "https://arbitrum.therpc.io/YOUR_API_KEY") and keep it as a property of your service. Every network call — getBalance, prepareTransaction, send — is async throws, so invoke it from an async context or inside a Task, and use try await. Arbitrum One's sub-second sequencer confirmations keep these awaits short, which suits the responsive feel expected on iOS.
For a reactive Arbitrum One balance in SwiftUI, back your view with an ObservableObject view model and hold it with @StateObject; mark the balance @Published so the UI refreshes when a new value arrives. Trigger the async fetch inside a Task { } from a Button action, or attach it to the view with the .task modifier so it runs when the view appears. Updating @Published properties on the main actor keeps SwiftUI happy.
To call a deployed Arbitrum One contract, load its ABI JSON and build a contract instance with web3.eth.Contract(json:address:), then invoke a method by name with its parameters and .call() it. This covers reads against protocols already live on Arbitrum One — a GMX vault or a Uniswap pool — whose verified ABIs you can copy from https://arbiscan.io.
Define a typed EthereumError enum so your UI can distinguish an invalid address from a network failure or insufficient funds, and respond to each appropriately rather than showing one generic alert. Validate the address format — at minimum the 0x prefix and expected length — before making any Arbitrum One network call; catching a malformed address locally saves a wasted round trip and gives the user faster feedback.