NEO blockchain, programming tutorials, Javascript — 5

館長
Blockchain Under The Hood
2 min readMay 21, 2018

Communicate with RPC using protocol, and query its block height

neon-js

This is a series of how you can start to build a decentralized app on the top of NEO. Before moving forward, I will guide you the fundamental aspect before we get started.

I am a full-stack javascript developer and one of the contributors for NEO blockchain project.

How To Get Started

NEO blockchain, programming tutorials, Javascript — 1

Get Block Height

const axios = require('axios')const queryRPCBlockHeight = (url) => {  const jsonRequest = axios.create({
headers: {
'Content-Type': 'application/json'
}
})
const jsonRpcData = {
jsonrpc: '2.0',
method: 'getblockcount',
params: [],
id: 1234,
}
return jsonRequest
.post(url, jsonRpcData)
.then(response => response.data)
}
-----------------------------------------queryRPCBlockHeight('http://seed2.neo.org:10332')
.then(responseFromRPC => {
responseFromRPC -> {
jsonrpc: '2.0',
id: 1234,
result: 2297813
}
})
Block Height of 2297813

Tip of the day

Blockchain under the hood is using distributed ledger technology to achieve decentralization.

Ledger VS Block
With each block being generated, there would be more transactions written in the ledger

What is block height?
The height of a block is the number of blocks that has been created from the genesis block(height of 0).

Why do we need it?
A distributed ledger means there are many copies of ledger across the world, and how do we know which ledger that we should be base on?
We usually choose the one that has the most blocks(block height as we call it)

Stay Tune

For coming Monday topic, I will look at the response message and see which one that might fit for the coming topic. Feel free to drop message to me if you want to suggest a topic for me.

I make one post on every Monday UTC+0 time zone, but if I have more than 500 claps, I make another post immediately.

Useful Link

Blockchain Programing
1.「NEO blockchain, programming tutorials, Javascript — 1
2.「NEO blockchain, programming tutorials, Javascript — 2
3.「NEO blockchain, programming tutorials, Javascript — 3
4.「NEO blockchain, programming tutorials, Javascript — 4
5.「NEO blockchain, programming tutorials, Javascript — 5

Blockchain Link List
Blockchain Posts List

About me
I am a full-stack javascript developer and one of the contributors for NEO blockchain project.

Build Decentralized Application with Javascript on the top of NEO?
NEO blockchain, programming tutorials, Javascript

If you consider yourself a talent?
Cobinhood Careers

--

--