Avalanche
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Avalanche
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Web3j is the primary JVM library for the Avalanche C-Chain, working with Java 8+ and Kotlin coroutines out of the box. Since the C-Chain is an EVM at chain ID 43114, Web3j points at https://avalanche.therpc.io/YOUR_API_KEY with no special configuration, and AVAX is the native token your transactions move. For Android apps, use the web3j-android artifact, which strips desktop-only dependencies that bloat or break an APK build. On the JVM, add it with Gradle: implementation "org.web3j:core:4.x.x".
Web3j supports Java 8+ and Kotlin coroutines out of the box, so the same C-Chain calls fit both a Spring backend and a coroutine-based mobile app. For Android, depend on the web3j-android artifact to exclude desktop-only dependencies and keep the build clean.
Build a client with Web3j.build(new HttpService("https://avalanche.therpc.io/YOUR_API_KEY")) and it is ready to query the C-Chain. The Java and Kotlin examples below share this single setup call; from there you read AVAX balances, fetch the gas price, and submit signed transactions through the same API.
On Android, run C-Chain calls off the main thread: launch them in viewModelScope.launch and switch to Dispatchers.IO so network IO never blocks the UI and triggers an ANR. The client setup is identical to the JVM — Web3j.build(HttpService("https://avalanche.therpc.io/YOUR_API_KEY")) — and viewModelScope ties the work to the ViewModel lifecycle so it is cancelled automatically when the screen goes away.
Rather than encoding calldata by hand, use the web3j CLI to generate Java or Kotlin wrapper classes from a Solidity ABI — for any C-Chain contract, your own or a protocol like Trader Joe. The generated wrapper exposes each contract method as a strongly typed call, so the compiler checks argument and return types and you load the contract at its deployed address with credentials, gas price, and gas limit.