Matrix AI Network Utils — Part 2.2: Accessing block info(JS, NodeJS), Beginner level

Matrix AI Network
3 min readSep 24, 2021

By: CognitiveProcessing

This tutorial is for educational purposes only, I’m not responsible for any losses, damages, or other liabilities which may occur by using any info/code provided here(or anywhere else it is posted).

I’m under no circumstances a Javascript professional (or a JS Ninja/Expert)!

The code is not production ready! (only for learning purposes)

In this guide, I’m going to show you how to access specific details from a block (for example transactions)

We will make use of the following package : ‘aiman’.

You can install it by using :

npm install aiman

We can initialize it with an HTTP provider like this:

If we would like to access info for the 5 mil block, for example, we can declare a variable then create a promise:

After solving the promise we will be able to access the following details:

We can also access the transactions info which has the following details:

In the next part I’m going to print the block hash + difficulty and all of the transactions hashes:

The output for block 5.000.000 should look like this:

Whole program (https://github.com/CognitiveProcessing/Matrix-AI-Network-Code-Snippets/blob/main/js/sendManTransaction.js)

For more documentation you can check dev.matrix.io

Matrix AI Network leverages the latest AI technology to deliver on the promise of blockchain.

FOLLOW MATRIX:

Website | Github | Twitter | Youtube

Telegram (Official) | Telegram (Masternodes)

Owen Tao (CEO) | Steve Deng (Chief AI Scientist) | Eric Choy (CMTO)

--

--

Matrix AI Network

The Matrix AI Network was founded in 2017. In 2023, we enter Matrix 3.0 blending neuroscience with our previous work to realize the vision of the Matrix films.