🐹
ChainRPC
  • Welcome to Chain-RPC Docs
  • Getting started
  • Networks
    • Ethereum
      • Concepts
        • Transaction types
        • Filters and subscriptions
      • How to
        • Authenticate requests
        • Make requests
        • Make batch requests
        • Choose a network
        • Subscribe to events
        • Interact with ERC-20 tokens
        • Add a network add-on
        • Secure a project
          • API key
          • API key secret
          • JWTs
          • Rate limits
          • Allowlists
        • Avoid rate limiting
      • JSON-RPC methods
        • eth_accounts
        • eth_blockNumber
        • eth_call
        • eth_chainId
        • eth_coinbase
        • eth_estimateGas
        • eth_feeHistory
        • eth_getBalance
        • eth_gasPrice
        • eth_getBlockByHash
        • eth_getBlockByNumber
        • eth_getBlockTransactionCountByHash
        • eth_getBlockTransactionCountByNumber
        • eth_getCode
        • eth_getLogs
        • eth_getStorageAt
        • eth_getTransactionByBlockHashAndIndex
        • eth_getTransactionByBlockNumberAndIndex
        • eth_getTransactionByHash
        • eth_getTransactionCount
        • eth_getTransactionReceipt
        • eth_getUncleByBlockHashAndIndex
        • eth_getUncleByBlockNumberAndIndex
        • eth_getUncleCountByBlockHash
        • eth_getUncleCountByBlockNumber
        • eth_getWork
        • eth_mining
        • eth_hashrate
        • eth_protocolVersion
        • eth_sendRawTransaction
        • eth_sendTransaction
        • eth_sign
        • eth_submitWork
        • eth_syncing
        • net_listening
        • net_peerCount
        • net_version
        • web3_clientVersion
        • Filter methods
          • eth_newFilter
          • eth_newBlockFilter
          • eth_newPendingTransactionFilter
          • eth_getFilterLogs
          • eth_getFilterChanges
          • eth_uninstallFilter
        • Subscription methods
          • eth_subscribe
          • eth_unsubscribe
    • Arbitrum
      • How to
        • Authenticate requests
        • Make requests
        • Choose a network
        • Secure a project
        • Get testnet ETH
      • JSON-RPC API methods
    • Aurora
      • How to
      • JSON-RPC API methods
    • Avalanche (C-Chain)
      • How to
      • JSON-RPC API methods
    • BNB Chain
      • How to
      • JSON-RPC API methods
    • Celo
      • How to
      • JSON-RPC API methods
    • Cube
      • How to
      • JSON-RPC API methods
    • Fantom
      • How to
      • JSON-RPC API methods
    • Gnosis
      • How to
      • JSON-RPC API methods
    • Heco
      • How to
      • JSON-RPC API methods
    • Klaytn
      • How to
      • JSON-RPC API methods
    • Optimism
      • How to
      • JSON-RPC API methods
    • OEC Chain
      • How to
      • JSON-RPC API methods
    • Polygon PoS
      • How to
      • JSON-RPC API methods
  • Custom APIs
    • Wellat SDK
    • DeX SDK
    • NFT SDK
Powered by GitBook
On this page
  • Error codes
  • Value encoding
  1. Networks
  2. Ethereum

JSON-RPC methods

This section lists the Ethereum JSON-RPC API endpoints. You can call these APIs using a variety of tools. These APIs (or a subset of them) are also used by some Ethereum-compatible networks such as:

  • ​Arbitrum​

  • ​Optimism​

  • ​Polygon PoS​

  • ​Palm​

  • ​Aurora​

  • ​Avalanche (C-Chain)​

  • ​Celo​

Error codes

The following list contains all possible error codes and associated messages:

Code
Message
Meaning
Category

-32700

Parse error

Invalid JSON

standard

​

-32600

Invalid request

JSON is not a valid request object

standard

​

-32601

Method not found

Method does not exist

standard

​

-32602

Invalid params

Invalid method parameters

standard

​

-32603

Internal error

Internal JSON-RPC error

standard

​

-32000

Invalid input

Missing or invalid parameters

non-standard

​

-32001

Resource not found

Requested resource not found

non-standard

​

-32002

Resource unavailable

Requested resource not available

non-standard

​

-32003

Transaction rejected

Transaction creation failed

non-standard

​

-32004

Method not supported

Method is not implemented

non-standard

​

-32005

Limit exceeded

Request exceeds defined limit

non-standard

​

-32006

JSON-RPC version not supported

Version of JSON-RPC protocol is not supported

non-standard

​

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

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:

Value

Validity

Reason

0x

invalid

empty not a valid quantity

0x0

valid

interpreted as a quantity of zero

0x00

invalid

leading zeroes not allowed

0x41

valid

interpreted as a quantity of 65

0x400

valid

interpreted as a quantity of 1024

0x0400

invalid

leading zeroes not allowed

ff

invalid

values 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

Property

Type

Description

[blockNumber]

The block in the canonical chain with this number

OR [blockHash]

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:

Value

Valid

Reason

0x

valid

interpreted as empty data

0x0

invalid

each byte must be represented using two hex digits

0x00

valid

interpreted as a single zero byte

0x41

true

interpreted as a data value of 65

0x004200

true

interpreted as a data value of 16896

0xf0f0f

false

bytes require two hex digits

004200

false

values must be prefixed

PreviousAvoid rate limitingNexteth_accounts

Last updated 2 years ago

Since there is no way to clearly distinguish between a Data parameter and a Quantity parameter, 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:

{}

{}

EIP-1898
Quantity
Data