BNB Smart Chain
Prêt à utiliser cela en production ?
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
BNB Smart Chain
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
Web3j is the de facto JVM gateway to BNB Smart Chain. One library serves both Java and Kotlin codebases. It runs on Java 8 and later and slots naturally into Kotlin coroutines, so a server-side service or a mobile client can read balances and broadcast transactions on chain 56. Pull it in through Gradle with implementation "org.web3j:core:4.x.x", and for Android targets swap in the web3j-android artifact, which strips out desktop-only dependencies that would otherwise bloat the APK.
The library asks nothing exotic of your toolchain: Java 8+ is the only baseline, and its CompletableFuture-based calls map cleanly onto Kotlin's suspending functions out of the box. One Android-specific note bears repeating: the artifact choice. Picked over the core jar, web3j-android keeps the dependency graph lean and avoids classes that don't belong on a phone.
Client creation follows a consistent two-step shape: wrap your endpoint in an HttpService, then hand that to the builder, Web3j.build(new HttpService("https://bsc.therpc.io/YOUR_API_KEY")). The returned Web3j instance is your handle to BNB Smart Chain, exposing every JSON-RPC call you need to inspect chain 56 or push signed transactions to it.
On Android the cardinal rule is to keep network work off the main thread. Block it and the UI freezes, after which the system may kill your app. Launch BSC calls inside viewModelScope.launch(Dispatchers.IO) so the request to chain 56 runs on a background dispatcher and results post back safely. The client construction itself is identical to any other JVM target, Web3j.build(HttpService("https://bsc.therpc.io/YOUR_API_KEY")); only the threading context changes.
Rather than hand-encode calldata, let the web3j CLI generate wrapper classes from a contract's Solidity ABI — point it at a BEP-20 or PancakeSwap ABI and it emits a Java or Kotlin class for that contract. The generated wrapper turns each on-chain function into a strongly typed method, so calling a token's balanceOf or transfer on chain 56 becomes an ordinary, compiler-checked method invocation instead of a stringly-typed RPC payload.