Lotus block explorer written in TypeScript for node.js
See it live: https://explorer.givelotus.org
- node.js >= 16.14.1
- mongodb 4.2.x
- lotusd (latest version)
Enter MongoDB cli:
$ mongo
Create databse:
> use explorerdb
Create user with read/write access:
> db.createUser( { user: "username", pwd: "password", roles: [ "readWrite" ] } )
*Note: If you're using mongo shell 4.2.x, use db.addUser
instead of db.createUser
git clone https://github.com/maff1989/lotus-explorer
cd lotus-explorer && npm install --production
cp ./settings.json.template ./settings.json
Make required changes in settings.json
npm start
Note: mongod must be running to start the explorer
As of Iquidus version 1.4.0 the explorer defaults to cluster mode, forking an instance of its process to each cpu core. This results in increased performance and stability. Load balancing is handled automatically and any instances that die will be restarted. For testing/development (or if you just wish to) a single instance can be launched with
node --stack-size=10000 bin/instance.js
To stop the cluster you can use
npm stop
sync.js (located in scripts/) is used for updating the local databases. This script must be called from the explorer's root directory.
Usage: node scripts/sync.js [database] [mode]
database: (required)
index [mode] Main index: coin info/stats, transactions & addresses
market Market data: summaries, orderbooks, trade history & chartdata
mode: (required for index database only)
update Updates index from last sync to current block
reindex Clears index then resyncs from genesis to current block
notes:
* 'current block' is the latest created block when script is executed.
* The market database only supports (& defaults to) reindex mode.
ZMQ
It is recommended to use the ZeroMQ on your lotusd in order to detect and process new blocks. A PHP script for ZMQ is included in the repo. To launch the script, navigate to the Explorer's top-level directory and run:
php scripts/zmq.php
Note: You must have the php-zmq
module installed on your system in order for this to work. Refer to the PHP documentation for instructions on how to install on your system.
Lotus Explorer is intended to be generic, so it can be used with any wallet following the usual standards. The node must be running with atleast the following flags
-daemon -txindex
It is also heavily advised against running lotusd with the wallet functionality enabled. In order to disable, add the following line to your ~/.lotus/lotus.conf
file:
disablewallet = 1
Ensure mongodb is not exposed to the outside world via your mongo config or a firewall to prevent outside tampering of the indexed chain data.
script is already running.
If you receive this message when launching the sync script either a) a sync is currently in progress, or b) a previous sync was killed before it completed. If you are certian a sync is not in progress remove the index.pid from the tmp folder in the explorer root directory.
rm tmp/index.pid
exceeding stack size
RangeError: Maximum call stack size exceeded
Nodes default stack size may be too small to index addresses with many tx's. If you experience the above error while running sync.js the stack size needs to be increased.
To determine the default setting run
node --v8-options | grep -B0 -A1 stack_size
To run sync.js with a larger stack size launch with
node --stack-size=[SIZE] scripts/sync.js index update
Where [SIZE] is an integer higher than the default.
note: SIZE will depend on which blockchain you are using, you may need to play around a bit to find an optimal setting
Copyright (c) 2021-2023 maff1989
Copyright (c) 2015, Iquidus Technology
Copyright (c) 2015, Luke Williams
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of Iquidus Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.