Git Product home page Git Product logo

ethereum-lite-explorer's Introduction

Ethereum Lite Explorer by Alethio

The Lite Explorer is a client-side only web application that connects directly to a Ethereum JSON RPC compatible node. This means you can have your own private Ethereum Explorer should you wish so. No need for servers, hosting or trusting any third parties to display chain data.

CircleCI Docker

WARNING v1.x.x is a breaking update from previous v0.x.x releases

NOTICE Please report any bugs using Github's issues

Contents

Technical Details

The project is built on a React/MobX and TypeScript stack, using the Alethio CMS, which allows us to add extensions dynamically through 3rd party plugins. The basic functionality of the explorer is implemented via a series of open-source core plugins, which we also use internally for our aleth.io platform. Please refer to Alethio CMS for documentation on the plugin system.

Project structure

📁ethereum-lite-explorer
├─📁dev             - dev server for serving the app
├─📁dist            - target folder for application that contains deployables
└─📁src             - source files
  ├─📁app (*1)      - application source code
  ├─📁assets        - static assets (e.g. images) that will be bundled together with the application
  └─📁public        - contains static assets that are copied to the dist folder as they are

(*1)
📁app
├─📁components      - React components
├─📁translation     - localized strings
├─📁util            - application-agnostic utilities. Ideally these would be in a separate repo/package.
└─📄index.ts         - entry point

Getting started

Prerequisites

Please make sure you have the following installed and running properly

Configuration

The application requires a JSON configuration file which is loaded at runtime but with different approaches for development vs production environments.

For development the config file is called config.dev.json located in the root of the repository. As for the production environment the config file is copied in the dist folder and renamed to config.json.

The dist is the target folder for the built application that needs to be served by an HTTP server.

Here are 2 sample config files as starting point.

Config name Description
config.default.json Default configuration file which contains the core plugins of the app that are enough to run the explorer.
config.ibft2.json Configuration file that has the default core plugins plus an extra one useful for IBFT2 based chains that decodes the extraData field of a block.

The possibility to change the URL of the RPC enabled Ethereum node is done through the eth-lite core plugin. See the nodeUrl attribute for the plugin which has the default value set to https://mainnet.infura.io/.

For advanced configuration editing, please refer to the Alethio CMS documentation

Running in Docker

You can run the Lite Explorer in Docker by using the already published images on Docker Hub. The config file in the Docker images have the default values from the config.default.json sample file. By default it will connect to https://mainnet.infura.io/.

The simplest command to run it is

$ docker run -p 80:80 alethio/ethereum-lite-explorer

which will start a container on port 80 of your computer with a nginx embedded to serve the pre-build explorer. You can now open localhost in your browser and use it.

There are 2 env vars that can be passed in at runtime:

ENV var Description
APP_NODE_URL URL of RPC enabled node. (e.g. https://host:port, also supports Basic Auth by prepending user:pass@ to the host). This overrides in the config file the nodeUrl attribute of the eth-lite core plugin.
APP_BASE_URL It is used ONLY in index.html for og:tags. Overrides build time defined value.

For example if you want to connect to your node on localhost with all default configs run the following command:

$ docker run -p 80:80 -e APP_NODE_URL="http://localhost:8545" alethio/ethereum-lite-explorer

If more customization is needed, a full configuration file can be mounted in the application root (e.g. in the /usr/share/nginx/html folder).

$ docker run -p 80:80 -v /your-config-dir/config.json:/usr/share/nginx/html/config.json alethio/ethereum-lite-explorer

Setup/Build Instructions

Clone the explorer in a folder of your choosing

$ git clone https://github.com/Alethio/ethereum-lite-explorer.git
$ cd ethereum-lite-explorer

IMPORTANT: Make sure you are using npm 6.9+ for the next step. Older versions will NOT work due to alias feature usages introduced in npm 6.9.

Install npm packages

$ npm install

Copy the sample config file

$ cp config.default.json config.dev.json

Make necessary modifications into config.dev.json if needed. For development, you must also remove the version query strings ?v=#.#.# from the "plugins" URIs. Full list of configuration options available here

To start the development build run the following command:

$ npm run watch

This terminal will be kept open, as the above command continuously watches the source files for changes and triggers an incremental build on every change.

Alternatively, to build the minified version (used also for production) use:

$ npm run build

Since the app is using the Alethio CMS for using the core plugins the next step is to install them:

$ npm i -g @alethio/cms-plugin-tool
$ acp install --dev \
    @alethio/explorer-plugin-eth-common \
    @alethio/explorer-plugin-eth-lite \
    @alethio/explorer-plugin-3box

If you need other custom plugins like for example to decode the extraData field of a block for the IBFT2 based networks, you can install them at this step:

$ acp install --dev @alethio/explorer-plugin-eth-ibft2

The above command acp installs the plugins in the dist folder. Basically they will be copied, together with the base app.

IMPORTANT: Whenever you use npm run build or npm run build-dev the dist folder is emptied, thus the plugins are also deleted and they need to be reinstalled.

Finally, you can start the explorer with

$ npm start

Example setups

With Infura

  • Sign-up for an account or sign-in into your Infura account.

  • From the control panel, obtain your endpoint url for the network you are interested in (mainnet, ropsten, kovan, rinkeby). It will looks similar to https://mainnet.infura.io/v3/aa11bb22cc33......

  • Update config.dev.json file and set the nodeUrl attribute for the eth-lite plugin to your Infura endpoint.

Build and start Lite Explorer

$ npm run build && npm start

With Parity Light Client

This will allow you to run both your own node and explorer. No third-party dependencies. It will be slower to browse older data because it is fetching it real time from other ethereum peer nodes but it's fast to sync and low in resource usage.

Install Parity Ethereum through one of the convenient methods and start it with the --light cli flag.

As a simple step, if you have Docker, you could just run

$ docker run -d --restart always --name parity-light -p 127.0.0.1:8545:8545 parity/parity:stable --light --jsonrpc-interface all

Update config.dev.json file and set the nodeUrl attribute for the eth-lite plugin to http://127.0.0.1:8545.

Build and start Lite Explorer

$ npm run build && npm start

With Ganache

First of all, if you do not have it, download and install Ganache which will give you your own personal test chain.

After setting up and starting Ganache, update the config.dev.json file and set the nodeUrl attribute for the eth-lite plugin to http://127.0.0.1:7545.

Build and start Lite Explorer

$ npm run build && npm start

With Pantheon

This is a great way to use a full featured client, and to see how the explorer works with a private network.

First of all, if you do not have it, download and install Pantheon stable release.

To get started, run a Pantheon node with the HTTP and WebSockets JSON-RPC services enabled, allowing traffic from all hosts and CORS origins:

$ pantheon --host-whitelist="*" --rpc-http-cors-origins="*" --rpc-http-enabled --rpc-http-host=0.0.0.0 --rpc-ws-enabled --rpc-ws-host=0.0.0.0

(Note: using "*" values for host whitelist and CORS origins is not a recommended way to run a production node securely, this configuration is intended for test or developement purpose only. For more information about these options, refer to the Pantheon CLI reference).

After running Pantheon, update the config.dev.json file, and set the nodeUrl attribute for the eth-lite plugin to http://127.0.0.1:8545.

Build and start Lite Explorer

$ npm run build && npm start

Example Deployments

surge.sh

Surge.sh is a simple, single-command web publishing service that you can use to deploy your own version of the Lite Explorer.

Make sure you have set a proper and accessible APP_NODE_URL environment variable.

# copy and edit a config file
$ cp config.default.json config.json
# install surge
$ npm install --global surge
# build explorer
$ npm run build
# go to build dir
$ cd dist
# make push state work as it should
$ cp ../config.json config.json && cp index.html 200.html
# deploy
$ surge

ethereum-lite-explorer's People

Contributors

oancius avatar use-strict avatar tzapu avatar baxy avatar abancu avatar rizedr avatar rojotek avatar liviudm avatar codacy-badger avatar skmgoldin avatar nicolasmassart avatar

Watchers

James Cloos avatar

Forkers

cleancoindev

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.