
When encoding unformatted data (byte arrays, account addresses, hashes, bytecode arrays): encode as hex, prefix with "0x", two hex digits per byte. WRONG: 0x0400 (no leading zeroes allowed).WRONG: 0x (should always have at least one digit - zero is "0x0").

When encoding quantities (integers, numbers): encode as hex, prefix with "0x", the most compact representation (slight exception: zero should be represented as "0x0"). Both are passed with a hex encoding but with different requirements for formatting. Two key data types get passed over JSON: unformatted byte arrays and quantities. Read the full JSON-RPC API spec on GitHub (opens in a new tab) ↗. This is called the 'Engine API' and the specs are available on GitHub (opens in a new tab) ↗. This API is documented on the Beacon API webpage (opens in a new tab) ↗.Īn internal API is also used for inter-client communication within a node - that is, it enables the consensus client and execution client to swap data. However, consensus clients also have an RPC API that allows users to query information about the node, request Beacon blocks, Beacon state, and other consensus-related information directly from a node. This page deals mainly with the JSON-RPC API used by Ethereum execution clients. With these libraries, developers can write intuitive, one-line methods in the programming language of their choice to initialize JSON-RPC requests (under the hood) that interact with Ethereum.

Many JavaScript and backend API libraries exist to provide wrappers on top of the JSON-RPC API. While you may choose to interact directly with Ethereum clients via the JSON-RPC API, there are often easier options for dapp developers. We recommend checking the documentation of each client for the latest API support information. See individual client documentation for further details related to specific programming languages. Client implementationsĮthereum clients each may utilize different programming languages when implementing the JSON-RPC specification. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It defines several data structures and the rules around their processing.


JSON-RPC (opens in a new tab) ↗ is a stateless, light-weight remote procedure call (RPC) protocol. In order for a software application to interact with the Ethereum blockchain - either by reading blockchain data or sending transactions to the network - it must connect to an Ethereum node.įor this purpose, every Ethereum client implements a JSON-RPC specification (opens in a new tab) ↗, so there is a uniform set of methods that applications can rely on regardless of the specific node or client implementation.
