Skip to main content

JSON-RPC methods

This section contains the JSON-RPC API endpoints on the left sidebar. You can call these APIs using a variety of tools.

Error codes

You may encounter various errors when interacting with a network:

  • JSON-RPC errors: These are related to operations on the blockchain network. It means the server has received the JSON-RPC request but encountered an issue processing it. Causes might include invalid parameters, a method not found, or execution errors related to the requested operation.

  • HTTP errors: These happen at the transport layer during data transmission to the blockchain network. They could stem from Infura-related issues like rate limits, API key problems, or service availability issues.

  • Smart contract errors: These arise during attempts to execute transactions in the EVM involving smart contracts.

JSON-RPC errors

Error codes returned by Infura's RPC service network APIs can vary slightly between implementations, but they follow the JSON-RPC 2.0 specification and Ethereum-specific conventions.

The following table lists the error codes, their messages, and meanings. The "Standard" category includes common JSON-RPC errors, while the "Non-standard" category encompasses server errors defined by the implementation.

CodeMessageMeaningCategory
-32003Transaction rejectedThe transaction could not be created.Non-standard
-32002Resource unavailableThe requested resource is not available.Non-standard
-32001Resource not foundThe requested resource cannot be found, possibly when calling an unsupported method.Non-standard
-32700Parse errorThe JSON request is invalid, this can be due to syntax errors.Standard
-32004Method not supportedThe requested method is not implemented.Non-standard
-32601Method not foundThe method does not exist, often due to a typo in the method name or the method not being supported.Standard
-32005Limit exceededThe request exceeds your request limit.Non-standard
-32006JSON-RPC version not supportedThe version of the JSON-RPC protocol is not supported.Non-standard
-32600Invalid requestThe JSON request is possibly malformed.Standard
-32000Invalid inputMissing or invalid parameters, possibly due to server issues or a block not being processed yet.Non-standard
-32602Invalid argumentInvalid method parameters. For example, "error":{"code":-32602,"message":"invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go value of type common.Hash"} indicates the 0x prefix is missing from the hexadecimal address.Standard
-32603Internal errorAn internal JSON-RPC error, often caused by a bad or invalid payload.Standard
-33000Payment RequiredYou've reached your daily credit quota limits.Non-standard
-33100ForbiddenThe request is forbidden, your account could possibly be suspended.Non-standard
-33200Too Many RequestsYou have surpassed your allowed throughput limit. Reduce the amount of requests per second or upgrade for more capacityNon-standard
-33300Too Many RequestsYou have surpassed your user-defined key throughput limit setting. To make more requests, adjust your rate limit.Non-standard
-33400Too Many RequestsYou have surpassed your user-defined key daily credit limit setting. To make more requests, adjust your daily quota limit.Non-standard

Example error response:

{
"id": 1337
"jsonrpc": "2.0",
"error": {
"code": -32003,
"message": "Transaction rejected"
}
}

HTTP errors

Infura-specific error codes or messages could include errors for rate limits, API key issues, or service availability problems.

CodeMessageMeaning
400Bad requestIncorrect HTTP Request type or invalid characters, ensure that your request body and format is correct.
401UnauthorizedThis can happen when one or multiple security requirements aren't met. Example responses: project id required in the URL, invalid project id, invalid project id or project secret, invalid JWT.
402Payment RequiredYou've reached your daily quota on your free plan. Upgrade your plan to continue using the product for the day.
403ForbiddenThe request was intentionally refused. For example, an account that has been banned, or has not completed verification in a timely manner might receive this error.
429Too Many RequestsYou have reached your plan's daily throughput limits, or user-defined throughput limits. To continue making requests, reduce the requests per second, upgrade your plan, or review your user-defined limits. Refer to the Avoid rate limiting topic for more information. Example response: "error": {"code": -32005, "message": "project ID request rate exceeded"}.
500Internal Server ErrorError while processing the request on the server side.
502Bad GatewayIndicates a communication error which can have various causes, from networking issues to invalid response received from the server.
503Service UnavailableIndicates that the server isn't ready to handle the request.
504Gateway TimeoutThe request ended with a timeout, it can indicate a networking issue or a delayed or missing response from the server.

Smart contract errors

When interacting with smart contracts, you might also encounter errors related to the execution of transactions in the EVM:

  • Out of gas: The transaction doesn't have enough gas to complete.
  • Revert: The transaction was reverted by the EVM, often due to a condition in the smart contract code.
  • Bad instruction: The transaction tried to execute an invalid operation.
  • Bad jump destination: A jump was made to an invalid location in the smart contract code.

Value encoding

Specific types of values passed to and returned from Ethereum RPC methods require special encoding:

Quantity

A Quantity (integer, number) must:

  • Be hex-encoded.
  • Be 0x-prefixed.
  • Be expressed using the fewest possible hex digits per byte.
  • Express zero as 0x0.

Examples Quantity values:

ValueValidityReason
0xinvalidempty not a valid quantity
0x0validinterpreted as a quantity of zero
0x00invalidleading zeroes not allowed
0x41validinterpreted as a quantity of 65
0x400validinterpreted as a quantity of 1024
0x0400invalidleading zeroes not allowed
ffinvalidvalues must be prefixed

Block identifier

The RPC methods below take a default block identifier as a parameter.

  • eth_getBalance
  • eth_getStorageAt
  • eth_getTransactionCount
  • eth_getCode
  • eth_call
  • eth_getProof

Since there is no way to clearly distinguish between a Data parameter and a Quantity parameter, EIP-1898 provides a format to specify a block either using the block hash or block number. The block identifier is a JSON object with the following fields:

PropertyTypeDescription
[blockNumber]{Quantity}The block in the canonical chain with this number
OR [blockHash]{Data}The block uniquely identified by this hash. The blockNumber and blockHash properties are mutually exclusive; exactly one of them must be set.
requireCanonical{boolean}\(optional) Whether or not to throw an error if the block is not in the canonical chain as described below. Only allowed in conjunction with the blockHash tag. Defaults to false.

Data

A Data value (for example, byte arrays, account addresses, hashes, and bytecode arrays) must:

  • Be hex-encoded.
  • Be 0x-prefixed.
  • Be expressed using two hex digits per byte.

Examples Data values:

ValueValidReason
0xvalidinterpreted as empty data
0x0invalideach byte must be represented using two hex digits
0x00validinterpreted as a single zero byte
0x41trueinterpreted as a data value of 65
0x004200trueinterpreted as a data value of 16896
0xf0f0ffalsebytes require two hex digits
004200falsevalues must be prefixed