Domain Steem with JavaScript: Lesson #1 - Introduction to Steem Blockchain and RPC Nodes

in #steemjs-s22w12 days ago

RPC Nodes.png

Edited by Canva

Hello steemians,

Here is my homework for SLC22 Week 1, with the corresponding tasks assigned by @alejos7ven!

What is your understanding about RPC Nodes?

My understanding is that RPC nodes, which stand for Remote Procedure Call Contracts, are basic interfaces that allow developers to interact with the Steem blockchain remotely. These nodes act as primary access points to the network, providing an organized way to perform specific functions without the node’s infrastructure needing to be managed by developers.

As for reading data, RPC nodes provide access to various and detailed information, such as account balances, transaction records, block details, publications or even votes recorded on the network, as for sending transactions, it allows developers to modify data on the blockchain by performing actions such as publishing content, transferring funds or voting on posts and comments.

Each RPC node is made up of a set of plugins that define the functionality available to developers, and the "condenser_api" plugin is among the most used, as it contains many common methods used to interact with the Steem network, whether To retrieve information or write new data, these nodes are often managed by witnesses, who act as validators on the network, or by other trusted parties such as Steemit Inc. For example, one of the RPC nodes The most popular ones available is provided by Steemit Inc via "https://api.steemit.com", a public interface that allows developers to send HTTP POST requests using JSON formatted data, however, this address does not is not a traditional website, but rather a dedicated interface for communicating with the Steem blockchain.

Therefore, I understand that RPC nodes are of fundamental importance in the accessibility of the Steem blockchain for developers, since they provide an efficient, integrated and reliable method for interacting with this technology, whether by reading precise information or executing complex transactions, while allowing smooth and adaptable integration into a variety of development environments, without requiring the establishment of heavy or complicated technical infrastructure.

Explore the Steem Developers Portal (https://developers.steem.io) and fetch data using JavaScript or Python from at least 3 methods of condenser_api plugin (Don't use get_block method)

To interact with the Steem API and retrieve information, I was able to explore the Steem developer portal and retrieve useful and diverse data, the three methods, get_accounts, get_dynamic_global_properties, and get_discussions_by_created, helped me allows you to efficiently interact with the blockchain, view information about a specific account, monitor overall network properties, and review the most recent discussions.

Node RPC.PNG

  • get_accounts method

This method allows you to retrieve detailed information about a specific account on the Steem blockchain. In this example, I used my account name kouba01.

24.PNG

Output

25.PNG

  • get_dynamic_global_properties Method

This method provides global information about the current state of the blockchain. This information includes:

  • The number of the last block produced.
  • The date and time the last block was produced.
  • The current rewards.
  • Global statistics such as inflation and the number of active accounts.

This is a useful method for monitoring the health and activity of the blockchain.

22.PNG

Output

23.PNG

  • get_discussions_by_created method

This method lists the recently created posts on the Steem blockchain. It takes as parameter an object containing options, such as limit, which specifies the number of posts to retrieve.

20.PNG

Output

21.PNG

Get the information of a random block between 1,000,000 and 1,500,000 and write a program that shows who created that block and the date it was created.

This program uses the Node.js fetch library to interact with the Steem API via the condenser_api plugin. The main customApi function allows you to send HTTP POST requests to the Steem API by taking as parameters the address of the RPC node, the name of the method called and the parameters needed for this method. In this case, the method used is condenser_api.get_block, which retrieves the information of a given block.

image.png

A random block is generated in the specified range using the mathematical formula Math.floor(Math.random() * (1500000 - 1000000 + 1)) + 1000000, thus ensuring that each execution of the program queries a different block.

image.png

When executed, the program displays a message such as:

image.png


Thank you very much for reading, it's time to invite my friends @analp, @crismenia, @eliany to participate in this contest.

Best Regards,
@kouba01

Sort:  
Loading...
Loading...