Ethereum Asked by Asmita Dhungana on December 25, 2021
I’m sorry. This might be a silly question but I am very much new to backends and networking protocols. I can write decent smart contracts but I don’t know much about the backend.
So… I wanted to learn how I can build an API to get transaction results from transaction hashes. What I got stuck is the very first place… I happened to know that REST API, JSON RPC, RPC, SOAP, GraphQL all are network protocols. But since REST is so famous, why do Ethereum and Blockchain use JSON-RPC calls and not REST.
I’d searched the internet for it but could find no distinct reason that can make me understand. Happened to get it that JSON RPC calls are direct and faster…
I really am a beginner in this so can I get a simple analogy and a precise reason from this talented community please?
JSON-RPC is not a behaviour of the Ethereum network - Ethereum clients don't talk to each other via JSON-RPC - it's just a notation to encode a remote procedure call that some Ethereum client can interpret as commands sent by the users, and they can respond to those requests in a standard manner.
JSON-RPC is easy to implement, it's easy to read and to debug - it's just text in a JSON notation - and this is why is so widespread in many applications, not only in Blockchain clients.
REST is not meant to send commands at all but to manage resources, and in particular it allows HTTP to act as a sort of CRUD manager for web resources. With REST you can Create, Read, Update and Delete a resource managed by the server you are sending the REST request to.
The above features are usually not what Blockchain clients need to offer to their user. Blockchain clients usually need to expose commands to be called, and to respond with results. This is why usually JSON-RPC is a better option.
Answered by Giuseppe Bertone on December 25, 2021
Your question assumptions are false, because there are other API protocols like graphQL for Ethereum.
Why everyone is using JSON-RPC is because Satoshi chose JSON-RPC for Bitcoin back in 2009. Then everyone followed the suit. Not for a particular reason, but because of cargo culting and so on, though JSON-RPC has some good properties like being curl
able and human readable.
Answered by Mikko Ohtamaa on December 25, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP