Skip to content

Error Codes

Reference for JSON-RPC and nodewell-specific error codes.

JSON-RPC Standard Errors

CodeMessageDescription
-32700Parse errorInvalid JSON
-32600Invalid RequestRequest object invalid
-32601Method not foundMethod does not exist
-32602Invalid paramsInvalid method parameters
-32603Internal errorInternal JSON-RPC error

Ethereum Errors

CodeMessageDescription
-32000Server errorGeneric server error
-32001Resource not foundBlock/tx not found
-32002Resource unavailableRequested data unavailable
-32003Transaction rejectedTransaction rejected
-32004Method not supportedMethod not supported on this network

nodewell Specific Errors

CodeMessageDescription
-32005Rate limit exceededToo many requests
-32006Invalid API keyAPI key invalid or missing
-32007API key expiredAPI key has expired
-32008Insufficient quotaDaily quota exceeded

Error Response Format

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32602,
    "message": "Invalid params",
    "data": "Missing required parameter: address"
  }
}

Common Issues & Solutions

Invalid API Key

json
{
  "error": {
    "code": -32006,
    "message": "Invalid API key"
  }
}

Solution: Check your API key is correct and included in the URL.

Rate Limit Exceeded

json
{
  "error": {
    "code": -32005,
    "message": "Rate limit exceeded. Please retry after 1 second."
  }
}

Solution: Implement retry logic with exponential backoff:

javascript
async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (error.code === -32005 && i < maxRetries - 1) {
        await new Promise(r => setTimeout(r, 1000 * Math.pow(2, i)));
        continue;
      }
      throw error;
    }
  }
}

Block Not Found

json
{
  "error": {
    "code": -32001,
    "message": "Block not found"
  }
}

Solution: Verify the block number/hash exists. For recent blocks, wait for confirmation.

Execution Reverted

json
{
  "error": {
    "code": 3,
    "message": "execution reverted",
    "data": "0x..."
  }
}

Solution: The contract call reverted. Decode the error data using your library of choice to read the revert reason.

Gas Estimation Failed

json
{
  "error": {
    "code": -32000,
    "message": "gas required exceeds allowance"
  }
}

Solution: The transaction would fail. Check:

  • Sufficient balance for gas
  • Contract logic doesn't revert
  • Correct parameters

Error Handling Examples

JavaScript

javascript
try {
  const result = await provider.call(tx);
} catch (error) {
  switch (error.code) {
    case -32005:
      console.log('Rate limited, retrying...');
      break;
    case -32602:
      console.log('Invalid parameters:', error.message);
      break;
    default:
      console.error('RPC error:', error);
  }
}

ethers.js

javascript
import { isError } from 'ethers';

try {
  await contract.someMethod();
} catch (error) {
  if (isError(error, 'CALL_EXCEPTION')) {
    console.log('Contract reverted:', error.reason);
  } else if (isError(error, 'NETWORK_ERROR')) {
    console.log('Network issue');
  }
}