Base
准备好在生产环境中调用了吗?
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
Base
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
Web3j is the primary JVM library for Base, working with Java 8+ and Kotlin coroutines out of the box. Because Base is an EVM-equivalent OP Stack rollup with ETH gas, Web3j's standard eth* methods reach Base at https://base.therpc.io/YOUR_API_KEY (chain ID 8453) with no special configuration. For Android apps, use the web3j-android artifact, which strips desktop-only dependencies that would otherwise bloat or break the build. Add the core library via Gradle: implementation "org.web3j:core:4.x.x".
Web3j supports Java 8+ and integrates cleanly with Kotlin coroutines out of the box, so Base calls fit naturally into a suspend function. For Android targets, depend on the web3j-android artifact to exclude desktop-only dependencies and keep your APK lean.
Create a client with Web3j.build(new HttpService(nodeUrl)), passing your Base endpoint https://base.therpc.io/YOUR_API_KEY as nodeUrl. The returned Web3j instance is the entry point for every balance query, transaction, and contract call against Base; build it once and reuse it across your app.
On Android, never run a Base RPC call on the main thread — launch it with viewModelScope.launch and switch to Dispatchers.IO so the UI stays responsive while the request is in flight. The connection itself is identical to the desktop case: Web3j.build(HttpService("https://base.therpc.io/YOUR_API_KEY")). Base's ~2s blocks and low ETH fees make it well-suited to consumer mobile apps that confirm actions quickly.
Use the web3j CLI to generate Java or Kotlin wrapper classes from a Solidity ABI, so calling a contract on Base becomes ordinary typed method invocation instead of hand-encoding parameters. The generated wrappers expose type-safe methods for both reads and writes, catching argument mistakes at compile time. Grab the ABI of any verified Base contract from https://basescan.org to feed the generator.