Skip to content

Using nanook

Luke Duncalfe edited this page Apr 9, 2021 · 16 revisions

First steps

Log into your node and fire up the Ruby CLI, like irb or pry.

Then try these steps to begin exploring.

Connect

You'll need to know which host and port the Nano RPC is running on in order to connect.

If you've installed nano on your server using docker, you can use "http://ip6-localhost:7076". Otherwise, check your node's config-rpc.toml file, and cat /etc/hosts might give you a clue.

Let's assume we're using the docker image:

require 'nanook'

nanook = Nanook.new("http://ip6-localhost:7076")

If we want to test the connection details are correct:

nanook.rpc.test # => true

We would see an error if we can't connect.

Explore

If your node is still bootstrapping with the network, it might not have a lot of confirmed blocks synchronized yet, in which case it won't know much about blocks or accounts on the network.

Let's check:

node = nanook.node
node.block_count # => {:cemented=>2, :count=>2, :unchecked=>10695575}
node.sync_progress # => 1.869897050947963e-05

We still have a long time to wait.

Let's grab the first synchronizing block (also called an unchecked or unconfirmed block):

block = node.synchronizing_blocks(limit: 1).keys.first
block.exists? # => false

It's considered to not exist because it's unconfirmed, but if we say that unchecked is okay:

block.exists?(allow_unchecked: true) # => true

Let's have a look at the nano network:

nanook.network_telemetry

There's a lot of stats about the overall state of the network.

One thing in particular is the genesis_block, the first block of the Nano network. Let's check that out:

genesis_block = nanook.network_telemetry[:genesis_block]
genesis_block.exists? # => true - Great!
Clone this wiki locally