Setting up a Rise Node and using the Python API

in #bitcoin7 years ago (edited)

I’ve been playing around with Rise for a couple months now, and am absolutely loving it! I’ve noticed a few people complaining about the Python API and lack of documentation. It’s not entirely the case, and the documentation is hidden in the code! I’ll go over it here. This document is to help you setup a Rise-Node and then install the python API to begin exploring it!

First step is to make sure you have all the minimum requirements to run the Node. The installation is really easy, provided you meet system requirements. First off, you cannot setup a Rise-Node natively on Windows. You need to use the latest version of Ubuntu, the latest version of NodeJS and because I’ll be using the Python API to explore the blockchain, you’ll need the latest version of Python (3.6.2 is the latest version). Installing an operating system and software is beyond the breadth of this tutorial so I’ll leave you to google that.

Next you want to get your Rise Node and get it running. Run the following four commands and it’ll be up and running! You can view the GitHub and the readme instructions
here

git clone -b master https://github.com/RiseVision/rise-node.git
cd rise-node
./rise_manager.bash install
./rise_manager.bash start

This should all run very smoothly. The process is very much automated and shouldn’t require much more then that. If it doesn’t work out the gate, make sure you check our NodeJS version via

node –version

And make sure it’s the latest version. You can view thier latest release here but you’ll want to install it via command line. Best way to update Node, as of the date posting this is:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Then try those four commands again and you should be off to the races! The best way to test if you’re connected is a simple curl call to the node.

curl http://127.0.0.1:5555/api/delegates

This should spam your terminal with a massive JSON array. If you don’t get massive amounts of text, it’s probably not up and running. Refer back to the ReadME for more information and troubleshooting.

Exploring the Blockchain

Your node is now up and running! The next step is for us to actually get exploring. From here we will have to get Rise-Py installed. Again, the Rise team have made this super simple to actually install. You’ll just be grabbing the git repo, then installing from source!

git clone https://github.com/RiseVision/rise-py.git
cd rise-py
sudo python3 ./setup.py install

And that’s pretty much it! You now just boot up python3 and connect to the node and begin exploring! The following are examples of using the API.

Connect to the Node

>>> from rise import RiseAPI 
>>> rise = RiseAPI('http://127.0.0.1:5555')

Get all forging delegates

>>> rise.delegates.get_list(limit=101, orderBy=’rank:asc’)[‘delegates’]

Get the highest voted delegate

>>> rise.delegates.get_list(limit=1, orderBy=’rank:asc’)[‘delegates’]

Get the lowest forging delegate

>>> rise.delegates.get_list(limit=101, orderBy=’rank:asc’)[‘delegates’][-1]

Get the most recent transactions

>>> rise.transactions.get_list(orderBy=’timestamp:desc’)[‘transactions’]

Get the most expensive transaction

>>> rise.transactions.get_list(orderBy=’amount:desc’, limit=1)[‘transactions’]

Get all the voters for a delegate

>>> rise.delegates.get_voters(public_key)[‘accounts’]

Get the Epoch for the blockchain

>>> rise.blocks.get_status()[‘epoch’]

Get the total number of transactions ever!

>>> rise.transactions.get_list()[‘count’]

Get total number of delegates

>>> rise.delegates.get_list()[‘totalCount’]

Register as a delegate

>>> rise.delegates.enable(secret, ‘Davion’, secret2)

Those are most of my little cheats! This should help you grab the finer details of the Python API. If you want more specific information python’s Help command works for all the Rise API functions. They aren’t super detailed but it’s something to go off of.

>>> help(rise.delegates.enable)

Coin Marketplace

STEEM 0.20
TRX 0.24
JST 0.038
BTC 96590.30
ETH 3333.92
USDT 1.00
SBD 3.16