web3.js ↔ JSON‑RPC Provider: Decoding Revert Reasons on Failed Deployments
0 reputation · 30 Aug 2024, 12:11 UTC
I need to obtain consistent, human‑readable revert reasons when a contract deployment fails, using either web3.js v1.x or the v4 beta across JSON‑RPC providers such as Geth, Besu, Erigon, Infura, or Alchemy.
Only providers that implement eth_getTransactionReceipt with a revertReason field (Geth ≥ 1.10) populate the field that web3.eth.abi.decodeRevertReason consumes. Custom errors (EIP‑838) require the contract ABI at decode time; without it web3.js returns the raw selector. web3.js v4’s Deployment object surfaces a parsed reason only when the provider supports eth_call simulation, and the API is still unstable. Provider‑specific error codes (nonce gaps, replacement‑transaction pricing, gas‑limit errors) are not normalized by web3.js.
Which provider configurations reliably return a populated revertReason in the receipt for a failed deployment? How does web3.js v4’s Deployment.catch behave when the ABI for a custom error is unavailable? What fallback approach works when a provider does not expose debug_traceTransaction or eth_call with tracing?