HttpProvider throws plain RpcError objects ({ code, message, data? }) directly from JSON-RPC responses and HTTP failures rather than instanceof ProviderRpcError. Always check error properties with a type guard (isRpcError) instead of relying solely on instanceof.
import type { RpcError } from '@tevm/voltaire/provider';export function isRpcError(error: unknown): error is RpcError { return ( typeof error === 'object' && error !== null && 'code' in error && typeof (error as { code: unknown }).code === 'number' && 'message' in error && typeof (error as { message: unknown }).message === 'string' );}
Contract revert / require (revert bytes in error.data)
-32000
Invalid input / execution error
Execution revert, insufficient funds, nonce too low, or bad gas
-32001
Resource not found
Missing block, header, or transaction
-32002
Resource unavailable
Node still syncing or pruned state
-32003
Transaction rejected
Mempool rejected transaction
-32004
Method not supported
Recognized but disabled RPC
-32005
Limit exceeded
Rate limit or block-range cap exceeded
Handling Contract Reverts
Contract reverts surface with code === 3 or code === -32000, often carrying ABI-encoded revert bytes in error.data (for example 0x08c379a0... for Error(string) or a 4-byte custom error selector):
Combine isRpcError with retryWithBackoff from @tevm/voltaire/utils so permanent errors fail immediately while rate limits (-32005) and transient server failures (-32603, -32002) back off exponentially: