Building decentralized mobile applications (dApps) and crypto wallets on Android involves frequent JSON-RPC communications with Ethereum, Polygon, Arbitrum, or Solana RPC nodes (via Infura, Alchemy, or QuickNode).
Debugging failed transactions is notoriously difficult when raw JSON-RPC responses only return opaque 4-byte revert signatures (0x08c379a0) or generic execution reverted messages without clear parameter decoding.
web3-chucker extends OkHttp to inspect, parse, and decode Web3 JSON-RPC transactions and smart contract revert errors directly on-device.
🏗️ Architecture: JSON-RPC Parsing & Revert Lookup Engine
-
Method-Aware RPC Filtering: Automatically tags and filters JSON-RPC methods (
eth_sendRawTransaction,eth_call,eth_estimateGas,personal_sign,solana_sendTransaction). -
4-Byte Revert Decoder: Translates opaque error selectors (e.g.
0x4e487b71->Panic(uint256)) into human-readable contract revert reasons. - Latency & Gas Tracking: Measures round-trip RPC execution latency and flags gas estimation spikes.
🛠️ Step-by-Step Implementation Guide
1. Add Gradle Dependency
dependencies {
// Debug builds: full JSON-RPC inspector & overlay UI
debugImplementation("io.github.zakayothuku:web3-chucker:1.0.0")
// Release builds: zero-overhead no-op artifact
releaseImplementation("io.github.zakayothuku:web3-chucker-noop:1.0.0")
}
2. Configure Web3ChuckerInterceptor with OkHttp
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(
Web3ChuckerInterceptor(
context = applicationContext,
maxContentLength = 250_000L,
decodeReverts = true
)
)
.build()
// Provide client to Web3j or custom RPC client
val web3j = Web3j.build(HttpService("https://mainnet.infura.io/v3/YOUR_KEY", okHttpClient))
3. Attach Floating Overlay
@Composable
fun WalletApp() {
Box(modifier = Modifier.fillMaxSize()) {
WalletNavHost()
if (BuildConfig.DEBUG) {
Web3ChuckerOverlay()
}
}
}
👉 GitHub Repository: github.com/zakayothuku/web3-chucker

Top comments (0)