Posts

How To Connect to BSC Node via GetBlock

avatar of @englishtv
25
@englishtv
·
·
0 views
·
2 min read

Hi everyone, its GetBlock and we’re going to demonstrate how the blockchain node is accessed via GetBlock’s instruments.

In this article we will connect an account of GetBlock API user to Binance Smart Chain, a smart contracts platform by a world-leading crypto exchange Binance. In 2021, Binance Smart Chain or BSC garnered attention due to its compatibility with Ethereum, low fees and high bandwidth. As such it is a go-to solution for early-stage dApps.

To start the demonstration, let’s experiment with Binance Smart Chain shared nodes. We open our Services bar in the upper left of the GetBlock’s main page and choose the ‘Shared Nodes’ menu. Then, we open the ‘Binance Smart Chain’ tab. Please notice that GetBlock is an official partner of this blockchain.

Let’s copy the endpoint address https://bsc.getblock.io/mainnet/ to the Postman terminal and choose ‘POST’ as the type of request.

In the ‘Headers’ tab, we need to customize the parameters of our connection. To start with, we input ‘x-api-key’ as the type of our key.

To fill the ‘VALUE’ string, we need to know our unique API key, i.e. the identificator of our account utilized by GetBlock. It can be copied from the ‘Your API settings’ segment of our account main dashboard.

Once this is done, we need to customize other settings of our request in the ‘Body’ tab. As we’re interested in ‘raw’ data, we choose ‘RAW’ as a type of data requested and JSON as data format.

To proceed with our request and to save our time, we need to copy its parameters from GetBlock documentation. It can be found in the ‘Documentation’ menu and ‘Available nodes methods’ section.

We find ‘Binance Smart Chain’ and choose the ‘eth_blockNumber’ command. It allows the user to identify the block head of the last mined block. Let’s copy this data to our request field and access the BSC by clicking ‘Send’. That’s it: the requested data appears in the ‘Result’ string below our request.

We can do the same via the command line using WebSocket API method. To do so, we need to copy the ‘wss’ endpoint address from ‘Documentation’ to the wscat string.

Then, we input ‘x-api-key’ and our API account as ‘header’.

As we’re connected to Binance Smart Chain, let’s copy the data from Postman as displayed.

Here’s the result!

Posted Using LeoFinance Beta