What i learned with DataHub PathWay`s

Назарчик Процичок
4 min readMar 28, 2021

--

Hi guys, today I want to share with you my experience with Figment Learn and help you try something new with me.

At first We’ll need to create an account to get started here : datahub.figment.io/sign_up

Here a very easy registration, I think you won’t have any problems with it, you just need to fill a your name, an email, password and choose your first blockchain - it will be Avalanche.

After successfull registration you will enter a main page which will look like that

Then in my protocols you should to pick Avalanche to start learning about it.

Here you will see a step which you need to complete to learn a base information about Avalanche and how it’s work

To complete first step you need to install on your PC next apps :

Visual Studio Code, Git and Node.Js — them you can download on any sites.

Let’s start
First our step will be creating a folder which named “Avaxlearning”

Now we need to start Visual Studio Code to start working with codes

When it starts we need to chose our folder which we created few steps ago

Click on file to choose your folder or try to combinate your keyword CTRL + K or CTRL + O to open it then choose your folder.

Then you need to open new terminal to write and start your node.

Now we need to create new directory for your project. Use command “npm init -y” in terminal and you should get this :

Next step will be installing new packages. You need to paste it to terminal for download them “npm install — save avalanche dotenv” and press enter

Now one of the most important steps of our learning we need to create .env and get our privatekey for a successful continuation

Here you need in 2nd line change you api key which you get on datahub

Now you need to create .gitignore with following code

Now we will create client.js and write here a next code :

// Load environment variables
require(“dotenv”).config()

// Load Avalanche SDK components
const { Avalanche } = require(“avalanche”)

if (!process.env.NODE_URL) throw “NODE_URL env var is not set!”
if (!process.env.NODE_API_KEY) throw “NODE_API_KEY env var is not set!”
if (!process.env.NETWORK_ID) throw “NETWORK_ID env var is not set!”
if (!process.env.NETWORK_NAME) throw “NETWORK_NAME env var is not set!”

// Configure Avalanche client from the DataHub url
const url = new URL(process.env.NODE_URL)
const client = new Avalanche(
url.hostname,
url.port,
url.protocol.replace(“:”, “”),
parseInt(process.env.NETWORK_ID),
“X”,
“C”,
process.env.NETWORK_NAME
)

// Apply DataHub API authentication token
client.setAuthToken(process.env.NODE_API_KEY)

module.exports = client

Next step will be creating a connect.js with following code :

// Load Avalanche client helper
const client = require(“./client”)

async function main() {
// Initialize the Info API client
const info = client.Info()

console.log(“Fetching network information…”)
const nodeVersion = await info.getNodeVersion()
const networkName = await info.getNetworkName()
const networkID = await info.getNetworkID()
const networkPeers = await info.peers()

console.log(“\nNetwork info:”)
console.log(“* Node version:”, nodeVersion)
console.log(“* Network name:”, networkName)
console.log(“* Network ID:”, networkID)
console.log(“* Connected Peers:”, networkPeers.length)
}

main().catch((err) => {
console.log(“We have encountered an error!”)
console.error(err)
})

Now we need to test and make sure all is done. You need in terminal write node connect.js
and if all is good you will see next input

Network info:
* Node version: avalanche/1.2.0
* Network name: fuji
* Network ID: 5
* Connected Peers: 34

If you get it, you should verify your step on datahub by clicking verify on first step, it take around 5 minutes

But if you get some problems you can connect with chat on discord where guys will help you as possible : https://discord.com/invite/fszyM7K

This project is very interesting and perspective, because here very-very fast transactions, minimum fees, so you definitely need to try it

In the end, I would like to thank Figment for the unsurpassed experience I gained during my studies

--

--

Назарчик Процичок
Назарчик Процичок

Written by Назарчик Процичок

Students which trying to try all in this world

No responses yet