Ethereum
Java / Kotlin
Web3j is the standard JVM gateway to Ethereum. It runs on Java 8 and up, and because its send() calls return plain values you can wrap them in Kotlin coroutines without any adapter — the Kotlin example below just marks the methods suspend. Pull it in through Gradle with implementation "org.web3j:core:4.x.x". For Android, swap the artifact for org.web3j:core:4.x.x-android, which strips out the desktop-only dependencies (like the Bouncy Castle provider that clashes with Android's) so the build stays clean and the APK stays small.
Web3j works on Java 8+ and plugs into Kotlin coroutines without extra glue. On Android, depend on the -android artifact instead of core so the desktop-only transitive dependencies are excluded and your Ethereum calls don't drag in conflicting crypto providers.
Web3j
Web3j.build(new HttpService(nodeUrl)) is the one line that connects you to Ethereum — pass https://ethereum.therpc.io/YOUR_API_KEY as the node URL and the returned Web3j instance carries every JSON-RPC method as a Java call. ethGetBalance(...).send() returns wei as a BigInteger, and Convert.fromWei scales it to ether. The Java and Kotlin classes below are line-for-line equivalents; pick the one that matches your codebase.
- GitHub: https://github.com/web3j/web3j
- Docs: https://docs.web3j.io
- Runs on Java 8+ and integrates with Kotlin coroutines
- Android-compatible build via the
-androidartifact - Generated smart contract wrappers for type-safe Ethereum calls
- CLI tools for codegen and project scaffolding
- Wallet support — key generation, signing, and account management
Android Support
On Android the API is identical — Web3j.build(HttpService("https://ethereum.therpc.io/YOUR_API_KEY")) builds the same client you'd use on a server. What changes is threading. Web3j's send() is blocking, and Android throws NetworkOnMainThreadException if you call it on the UI thread. Launch the work in viewModelScope.launch and move the blocking call onto Dispatchers.IO with withContext, so the Ethereum round-trip happens off the main thread and the UI thread stays free to render.
Smart Contract Integration
Rather than hand-encode calldata, run the web3j CLI over a Solidity ABI to generate a wrapper class. The command below emits a Java/Kotlin type where each Ethereum contract function is a real method with proper argument and return types, so transfer on an ERC-20 takes a String address and a BigInteger amount and the compiler checks them. Load the wrapper with YourContract.load(address, web3j, credentials, gasPrice, gasLimit) and call methods directly — .send() runs the read or submits the transaction.