Skip to main content

Error codes

Every failed request call rejects with an error object:

interface ProviderRpcError extends Error {
code: number;
message: string;
data?: unknown;
}

Handle the codes you can recover from, starting with the most common one — the user saying no:

try {
await provider.request({ method: 'eth_requestAccounts' });
} catch (error) {
switch (error.code) {
case 4001:
// User rejected — normal flow, don't show an error state.
break;
case -32002:
// A request is already pending — point the user at the wallet
// instead of firing the request again.
break;
default:
console.error(error);
}
}

Provider errors (EIP-1193)

CodeNameWhat it means for your dapp
4001User rejected requestThe user dismissed the approval. Expected behaviour — never retry automatically.
4100UnauthorizedThe account or method has not been authorised. Connect first with eth_requestAccounts.
4200Unsupported methodCore does not implement the method — for example eth_sign, which is rejected by design.
4900DisconnectedThe provider cannot serve any request. Listen for connect before retrying.
4901Chain disconnectedConnected, but not to the chain the request targets.

JSON-RPC errors (EIP-1474)

CodeNameTypical cause
-32700Parse errorMalformed request payload
-32600Invalid requestRequest object missing required fields
-32601Method not foundTypo in the method name, or a method the network's node does not expose
-32602Invalid paramsWrong parameter count, type, or encoding
-32603Internal errorThe node failed to process an otherwise valid request
-32000Invalid input / server errorCatch-all from the RPC node — inspect message
-32002Resource unavailable / request pendingAn approval window for the same request is already open

Practical rules

  • 4001 is not an error state. Users decline requests all the time; treat it as a cancelled action.
  • Don't queue duplicate prompts. If you receive -32002, the approval window is already open.
  • Log error.data. Contract reverts from eth_call and eth_estimateGas usually carry the revert reason there.