L13 – Communication of Ethereum Nodes (CBDE Course)

In this lecture we are talking about the way
Ethereum nodes communicate with clients. If you are programming a distributed application
then you need to get access to the blockchain somehow. Distributed applications usually have two
parts: One part is HTML/Javascript. The other part is some smart contract deployed
on the blockchain. And there is a standardized way for the communication
between the HTML/JS part, so, the website and the node that connects to the blockchain. It’s like there is a standardized way for
the communication between a MySQL database and the clients, just easier. The Blockchain node is communicating with
other blockchain nodes with the Ethereum Protocol. That’s what a blockchain node is implementing. This can be in various languages. For example Geth is written in the language
Go. Parity is written in Rust. And so on. But how do blockchain nodes really communicate
with the outside world? Good question! Every blockchain node must also implement
a way to do Json Remote Procedure Calls. It’s a so called JSON-RPC. This way it will let you run commands and
accept json arguments or return json objects through a standardized API. Let me give you an example directly here from
the Go-Ethereum Website: Eth.coinbase for example, will give you the
address of the coinbase. Or eth.accounts will give you an array of
stored accounts. Or eth.getBalance(…) will give you the balance
in wei of a certain account. So, now we know that Ethereum nodes implement
the Ethereum protocol. And they expose a an API to do JSON Remote
Procedure Calls. But how can we connect to such a node to talk
to that interpreter? Different nodes expose different methods,
but in general it should be possible to use either IPC or HTTP. IPC stands for Inter Process Communication
and is basically a file based pipe to interact with a server-like process. So for example you open Go-Ethereum or Geth
and then you can attach with another Go-Ethereum to the already running instance. This could happen via an ipc file. It is a very common method and we will be
doing it later in the course. The other very common method is connecting
to an ethereum node via HTTP. This way a website can connect to the node
like connecting to any other API. For example a weather API. Instead of requesting the weather in New York
City the website could request a specific transaction or block or create a new account,
sign a transaction and so on. There are also other methods, like WebSockets,
to connect to a node, but IPC and HTTP are the most common methods. So, what is your take away from this lecture? There are multiple Ethereum Node Implementations
out there. They all implement the Ethereum protocol to
talk to each other. And they need to implement an endpoint to
do JSON-RPC either via IPC or HTTP.

Add a Comment

Your email address will not be published. Required fields are marked *