WTF is JSON-RPC ?
Developers can often use a lot of different complex concepts to get to a final, easy-to-use product. JSON-RPC may be something that throws off most people when they see it mentioned, although it’s a data exchange protocol that allows a client to communicate with a server.
The client (i.e. a blockchain explorer or a wallet) communicates with a server (e.g. a blockchain node providing the application data) by issuing commands and listening to responses.
JSON-RPC is actually a combination of two separate concepts. These two concepts create the widely used JSON-RPC concept, which has been deployed across a number of blockchain applications. Let’s dive deeper into each concept.
TL;DR — JSON is a data format and RPC is a way of invoking a function on a server.
JavasScript Object Notation (JSON)
It was popularized in the early 2000s as an alternative to the then defacto web standard, which was Extensible Markup Language (XML). JSON has since largely replaced XML as it can represent numbers, strings, values, and collections effectively. Any programming language can interpret JSON data as long as it’s properly formed.
Developers often use JSON because of its flexibility and readability. Its data does not include pre-defined schemas or data definitions that need to be understood before work can be started, and data is exchanged in a readable format.
These two features mean developers’ productivity surges when they’re working with JSON. However, the format is not the most efficient to parse and transmit data, and competing formats often provide better optimizations.
It’s widely believed that the productivity gained by using JSON outweighs the performance of using other formats. When it comes to blockchain applications, simplicity leading to fewer errors may also mean added security.
Remote Procedure Call (RPC)
Remote Procedure Call (RPC) is the second component of JSON-RPC and, as its name implies, enables one machine to call a procedure off another. RPC’s origins date back to 1970, when researchers were figuring out how distributed applications could communicate remotely.
Since then, the internet has evolved to the point modern web architecture now heavily relies on Representational State Transfer (REST). Services using REST have been boosted by frameworks such as Ruby on Rails and NodeJS.
REST is ideal for applications where functions involve Creating, Reading, Updating, and Deleting records. These applications can, for example, be social media platforms where content is always being changed.
Blockchains are immutable so a REST architecture does not make the most sense. Instead, using RPC has allowed for a more direct connection to the blockchain. An RPC message is initiated by the client and sends a message to a server, such as a blockchain node for example.
The message is passed with all the required parameters to invoke a procedure. When a server receives that message, it unpacks the parameters and invokes the procedure before returning the result back to the client.
In web3, JSON-RPC is used as a protocol to read and write data to blockchains.
Sending the JSON from below to a Ethereum RPC endpoint would invoke the node’s function to return the latest block number.
“jsonrpc” : ”2.0″,
”method” : ”eth_blockNumber”,
”params” : ,
The node would respond with a JSON containing the latest block number:
“jsonrpc” : “2.0”,
“result” : “0xDF1657” // 14620247
All of this means that JSON-RPC is a protocol that uses JSON to encode requests and responses between clients and servers. JSON-RPC v2.0 was released in 2010 and provides a simple RPC mechanism for developers.
About OMNIA Protocol
By foreseeing the state of the current blockchain application network, we have committed to preparing, researching, and applying our technical expertise to our latest project, Omnia.
Omnia Protocol is a decentralized infrastructure protocol for securely accessing the blockchain so that no single point of failure will ever disrupt blockchain applications or wallets integrating with it.
Omnia’s solution is truly decentralized and requires zero technical knowledge. Therefore, all users can set up their nodes in little time and effort. Learn more about the technological marvel behind Omnia by following our Medium or reading our whitepaper.