-
Notifications
You must be signed in to change notification settings - Fork 1
Node Interaction
Justin Craig-Kuhn edited this page Jul 26, 2018
·
8 revisions
Information about a node can be obtained through the Nano::Node
object. To connect to the default host/port (localhost:7076
), call new
without parameters or Nano.node
for short.
node = Nano.node
# => #<Nano::Node:0x0000000001a8e250 @url="localhost:7076">>
To connect to a remote host, you must instantiate NanoRpc::Node
and pass it to proxy objects.
node = NanoRpc::Node.new(host: 'mynanonode', port: 9999)
# => #<Nano::Node:0x00007fb4c92c9040 @url="mynanonode:9999">
Now let's get information about the node/network.
node.version
# => {"rpc_version"=>1, "store_version"=>10, "node_vendor"=>"RaiBlocks 9.0"}
node.peers
# => {"[::ffff:1.46.4.222]:18210"=>"5", "[::ffff:1.127.110.163]:8615"=>"5", "[::ffff:2.30.88.14]:7075"=>"5", ... }
Let's look at the state of the network.
node.block_count
# => {"count"=>2411012, "unchecked"=>3156372}
node.total_supply
# => 133248291220723000000000000000000000001
Let's do some basic utility stuff.
node.nano_from_raw(amount: 10000000000000000000000000000000)
# 10000
node.key_create
# => {"private"=>"DF206504106CE8B51D46F26AEA9FF41D764AB9E6E9059651AE97C22D15A92218", "public"=>"04371A7D53CED8AFF75CEF4D7360BD283AE10CFF94E3E4E072C4AD632DC0F12C", "account"=>"xrb_133q5byo9mprozuosutfgfidtc3tw68hz795wmi97j7feepw3wbe9xp1pzwg"}