DATRICS UPDATES V2.4 | 28 NOVEMBER 2022

Web3 analytics with new connectors in Datrics

Web3 ecosystem is growing fast, along with it opportunities for the products built on blockchain. Datrics is the data analytics and data science partner for Web3, empowering blockchain teams with meaningful insights from on-chain and off-chain data. We have been building our expertise in blockchain and Web3 to help developers make better decisions and bring transparency to DeFi solutions.

In this release we have focused on the features that would make it easier to build analytics for blockchain. So let’s see what is new in Datrics.

Content

Build Web3 analytics with connectors to NEAR blockchain

Blockchains are packed with data and this information is open for everybody. It may seem that the case is solved, however, the next problem is insight. Datrics partners with developers to overcome challenges of Web3 analytics to derive useful information from blockchain.

We have added new bricks to Datrics.ai platform for analysts to fetch data and create transactions on NEAR blockchain. NEAR Fetch brick allows one to access the information of the specific smart contract and method. You may explore the methods on NEAR blocks. NEAR transaction allows analyst to call smart contract and record data on the blockchain.

Datrics pipeline to retrieve the balance for the account

Let’s look at the example of how it works. For instance, we need to get a NEAR balance for the nearcrowd.near account. With our no code platform you may do it in 3 steps without writing code.

1. NEAR Fetch

Call account name on the NEAR blockchain to retrieve the information. To configure the brick you need to define:

  • RPC - mainnet or testnet
  • Contract / Account name - nearcrowd.near
  • Request Type - View account

The result is represented as JSON:

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual

The information we requested is “amount". We may extract this using Flatten JSON and Math Formula bricks.

2. Flatten JSON to get the amount value from the smart contract response.

3. Math Formula to convert the value to NEAR coins. More on using Math formula.

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual

Finally, we can see that the NEAR balance for nearcrowd.near account is 46’462 NEAR.

More examples on how to fetch NEAR smart contract information.

REST API connector

Every analytics pipeline starts with the data, therefore we take the data connectors seriously. There is a new API connector coming in the Datrics release 2.4.

Rest API Request brick currently supports GET requests. User may set up the logic for the request without writing any code. You can setup the brick to connect to multiple APIs, as a result, all the requests will be made in parallel to reduce the time to get the data. Out put of the brick is a data frame with the responses to all call.

How to set up the REST API Request brick?

Here’s the example. Our goal is to retrieve the prices of the BNB and BTC tokens from Binance exchange. Binance provides the open apis to retrieve the latests data.

API connector in datrics.ai

The output of the brick contains: alias, URL, request result and retrieval time.

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual
API connector output dataframe

We have also used Flatten JSON brick to parse the results.

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual
Parsed API request results

Now we are ready to move forward with the data analysis!

Interested in experimenting with Datrics?

We are existed to help you do more. Book a demo!

Convert the data frame to JSON

Usually, the result of the pipeline is the data frame and/or a model. To work with smart contract and push the data on-chain, one would need to transform the data frame to json.

Here where new Prepare JSON becomes useful. Brick converts input data into a dictionary followed by JSON serialization format.

The transformation options we support:

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual

Let’s go through an example.

The input dataset to the brick has the following structure:

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual

We can form a JSON by connecting the dataset directly to the brick.

First, we select the ‘
dict’ option with no key defined and run the pipeline.

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual

As a result, we get the following output:

Add custom code bricks to your pipeline, set up the arguments, and run pipeline as usual

Check out our previous updates

Do you want to discover more about Datrics?

BACKED BY