Skip to content
Alethio's Light Weight Open Source Ethereum Explorer
TypeScript JavaScript HTML Shell Dockerfile CSS
Branch: master
Clone or download
Latest commit d39b7b6 Nov 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Fix CircleCi workflow missing ":" Jun 18, 2019
.docker Escape APP_BASE_URL before passing to sed Jul 2, 2019
.vscode React version (#25) Mar 27, 2019
dev Fix base path in html; add base path in dev server Jul 2, 2019
src Remove html base tag Oct 25, 2019
.dockerignore Upgrade to plugins-based explorer Jun 7, 2019
.gitignore Git ignore config.json Jun 18, 2019
.huskyrc React version (#25) Mar 27, 2019
.nycrc React version (#25) Mar 27, 2019
404.html Update gh-pages stuff for react SPA Mar 27, 2019
CHANGELOG.md Update changelog Nov 12, 2019
CONTRIBUTING.md Update en-US.json (#26) Apr 1, 2019
Dockerfile update docs for memento integration Nov 8, 2019
LICENSE.md Prepare initial release (#5) Dec 15, 2018
README.md update readme Nov 8, 2019
config.default.json Update cms and plugins Sep 10, 2019
config.ibft2.json Update cms and plugins Sep 10, 2019
config.memento.json update docs for memento integration Nov 8, 2019
package-lock.json Update package.json version Nov 12, 2019
package.json Update package.json version Nov 12, 2019
set-env-vars.js Set default nodeUrl if env is missing Jun 14, 2019
tsconfig.json Add support for base path Jul 1, 2019
tsconfig.test.json React version (#25) Mar 27, 2019
tsconfig.webpack.json React version (#25) Mar 27, 2019
tslint.json React version (#25) Mar 27, 2019
tslint.prod.json React version (#25) Mar 27, 2019
webpack.config.dev.js React version (#25) Mar 27, 2019
webpack.config.js Fix base path in html; add base path in dev server Jul 2, 2019
webpack.config.prod.js React version (#25) Mar 27, 2019

README.md

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 3 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.
config.memento.json Configuration file that has the default core plugins plus the memento plugins to use the Memento API as a data source

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 (e.g. https://my.app.tld). 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

Building from source

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-eth-memento \
    @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

Custom build arguments

The following env vars can be passed when building from source:

ENV var Description
APP_BASE_URL It is used ONLY in index.html for og:tags (e.g. https://my.app.tld)
APP_BASE_PATH Enables serving the app on a sub-path instead of the domain root (e.g. some/path/to/app).

Example: If serving the app from https://my.tld/path/to/app: $ APP_BASE_URL="https://my.tld" APP_BASE_PATH="path/to/app" npm run build

Example setups

With Memento

Memento is Alethio's open source tool for scraping and indexing Ethereum data from any web3-compatible node. The biggest advantage of using Memento as a data source is the indexed data which allows a faster access as well as the ability to show transactions on the account page.

If you don't have a Memento environment set up already, follow the instructions here

This requires Memento >= v1.1.0

Easiest way to run with Memento is to follow the steps from Running in Docker and mount config.memento.js as config file.

If you want a more customized setup, follow Building from source and the following steps

Build the Lite Explorer

$ npm run build

Install the necessary plugins

$ acp install --dev \
    @alethio/explorer-plugin-eth-common \
    @alethio/explorer-plugin-eth-memento \
    @alethio/explorer-plugin-3box

Copy the config file

$ cp config.memento.json config.dev.json

Modify the apiBasePath to point to Memento's API and, since we are running in dev mode, remove the version query strings ?v=#.#.# from the "plugins". The "plugins" section should look as follows:

"plugins": {
    "plugin://aleth.io/eth-common": {

    },
    "plugin://aleth.io/3box": {
        "ipfsUrlMask": "https://ipfs.infura.io/ipfs/%s"
    },
    "plugin://aleth.io/eth-memento": {
        "apiBasePath": "http://localhost:3001/api/explorer"
    }
},

Start the explorer

$ npm start

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

How to

Deploy to a domain sub-path

This case is supported only when building from source. You will have to pass the APP_BASE_PATH env variable to the build command. See Custom build arguments for reference and examples.

Show the network name

You can use our predefined module that shows the current network and an optional switch for navigating to other deployments/networks. To use this module, just add the following in config.json:

{
    // ...
    "pages": [
        // ...
        {
            "def": "page://aleth.io/dashboard",
            "children": {
                "content": [
                    {
                        "def": "module://aleth.io/dashboard/network",
                        "options": {
                            "networkName": "MyTestNet",
                            // This is optional
                            "otherNetworks": [
                                { "name": "Ethereum MainNet", "url": "https://aleth.io" }
                            ]
                        }
                    },
                    // ...
                ]
            }
        }
    ]
}

Link to a custom deployment of EthStats

If you have a custom deployment of our EthStats product, you can easily link to it from the main app toolbar using the predefined module. You'll have to edit config.json as shown below:

{
    "plugins": {
        // ...
        "plugin://aleth.io/eth-common?v#.#.#": {
            // ...
            "ethstatsUrl": "https://ethstats.io"
        }
        // ...
    },
    // ...
    "rootModules": {
        "toolbarTop": [
            // ...
            { "def": "module://aleth.io/toolbar/ethstats" }
        ],
        // ...
    }
}

Use a custom ETH currency symbol

If you are deploying for a private or test net, you can customize the main currency symbol by editing the config:

{
    "plugins": {
        // ...
        "plugin://aleth.io/eth-lite?v#.#.#": {
            // ...
            "ethSymbol": "GöETH"
        }
        // ...
    }
}

Show the transactions per account in account page

This module requires @alethio/explorer-plugin-eth-memento and access to call the api of a memento lite pipeline deployment. Edit the config:

{
    "plugins": {
        // ...
        "plugin://aleth.io/eth-memento?v#.#.#": {
            "ethSymbol": "GoETH",
            "apiBasePath": "http://memento-api.example/api/explorer"
        }
        // ...
    }
}

And add the module to account page:

{
    "pages": [{
        "def": "page://aleth.io/account",
        "children": {
            // ...
            "bottom": [
                { "def": "module://aleth.io/memento/account/txs" }
                // ...
            ]
        }
    }]
}

If you want to use Memento as a full backend replacement (recommended), see the With Memento section.

You can’t perform that action at this time.