Giter VIP home page Giter VIP logo

blockchain-api's Introduction

Helium Blockchain API

The Helium Blockchain API is a full blockchain node that exposes a JSON API which can be consumed by client applications like mobile applications or block explorers.

Build status

Installation

In order to run a local instance of the API a number of dependencies must be met.

(Note: These are required to build and run this node. Releases will be built in the future which require no external dependencies)

Homebrew

If using macOS make sure you have Homebrew installed. We'll use it to install the following dependencies

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Native Dependencies

$ brew install autoconf automake wget yasm gmp libtool cmake clang-format lcov doxygen libsodium

Elixir

For macOS:

$ brew install elixir

For Ubuntu/Debian, the default package manager is woefully out of date so follow elixir-lang.org instructions

$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
$ sudo apt-get update
$ sudo apt-get install esl-erlang
$ sudo apt-get install elixir

PostgreSQL

Install PostgreSQL if you haven't already and configure it with a default postgres/postgres user/pasword for now.

For macOS:

$ brew install postgresql
$ initdb /usr/local/var/postgres
$ brew services start postgresql

For Ubuntu/Debian,

$ sudo apt install postgresql
$ sudo -u postgres psql postgres
$ sudo -u postgres createuser --superuser $USER

NOTE: please edit config/prod.exs with your database credentials, otherwise it is assumed environment variables of DATABASE_USER, DATABASE_PASS, DATABASE_NAME, and DATABASE_HOST are present.

Clone blockchain-api

Clone this blockchain-api repo:

$ git clone https://github.com/helium/blockchain-api.git

Fetch Elixir Dependencies

cd into blockchain-api and use mix to fetch the erlang/elixir dependencies.

$ mix deps.get

Using the API

Building a release

Unless you're doing some development and need debugging you'll want to build a prod release.

cd into the blockchain-api folder and then run:

$ make release

Starting the API

Once the API has been built, you can start it by running:

$ make prod-start

This will connect the node to the main network and use the genesis block contained in the priv/prod folder.

You can check that the API is running by visiting http://localhost:4001/ from a web browser. You should get an ok response.

NOTE: by default, the config/prod.exs configuration file assumes that the base directory is /var/data/blockchain-api/prod and that the API server should be running on either the PORT environment variable or port 4001. Please edit the port and base_dir variables in prod.exs as desired for your configuration.

The API also expects an environment variable called GOOGLE_MAPS_API_KEY to be set, which is used to reverse lookup the hotspot location.

The API routes are temporarily documented on Postman.

Using the CLI

Now that everything is working as intended, we can run a couple of quick CLI commands.

Firstly, check whether we are connected to the network and have a few peers:

$ _build/prod/rel/blockchain_api/bin/blockchain-api peer book -s

We can also check our block height:

$ _build/prod/rel/blockchain_api/bin/blockchain-api status height

Or run:

$ _build/prod/rel/blockchain_api/bin/blockchain-api

To get a list of commands.

blockchain-api's People

Contributors

allenan avatar amirhaleem avatar chadbrading avatar chadbrading-zz avatar vihu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.