Ruby Steem tutorial 1 - Setup Ruby development environment for Steem blockchain on Ubuntu 16

Written by @inertia, Radiator is a Ruby API library for interacting with Steem blockchain network. I will write a series of tutorials to introduce how to use it. Let’s start with the environment setup now.

Install development libraries

First, we need to install essential libraries:

1
2
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev

Install rbenv

If you haven’t heard rbenv yet, I would highly recommend it. It makes your life much easier while managing different versions of Ruby and gems. Here are how to install rbenv:

1
2
3
4
5
6
7
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Install ruby

Now we are ready to install Ruby, let’s use the latest version, e.g. version 2.4.2:

1
2
rbenv install -v 2.4.2
rbenv global 2.4.2

Now we can run this command to test if Ruby is installed correctly:

1
ruby -v

Install radiator

We are ready to install radiator now, just type command as follows:

1
2
gem install radiator
rbenv rehash

Test if it works

Now let’s write a script to monitor all transfers in Steem blockchain:

1
2
3
4
5
6
7
require 'radiator'
stream = Radiator::Stream.new
stream.operations(:transfer) do |op|
puts "#{op.amount}: #{op.from} -> #{op.to}"
end

The output looks like:

1
2
3
4
5
6
7
8
9
10
0.100 STEEM: leyargoz -> steemdice1
1.400 STEEM: steemdice1 -> jameslano
0.045 SBD: boomerang -> connecteconomy
0.196 STEEM: steemdice1 -> leyargoz
0.001 SBD: boomerang -> crypto-btc
0.131 SBD: boomerang -> danielsaori
3.065 SBD: tezmel -> buildawhale
0.001 SBD: biddle -> null
0.179 SBD: boomerang -> dhouse
0.100 SBD: fury123 -> nettybot

Conclusion

We have setup Ruby development environments for Steem blockchains. In the following tutorials, we will see how to write interesting programs to interact with Steem blockchain.

Share