Nodejs implementation of REI-Network protocols
This project is under continuous development, all protocols and modules may be changed in the future, use it at your own risk
npm install @rei-network/cli --global
Usage: rei [options] [command]
Options:
-V, --version output the version number
--rpc open rpc server
--rpc-port <port> rpc server port
--rpc-host <port> rpc server host
--rpc-api <apis> rpc server apis: debug, eth, net, txpool, web3
--p2p-tcp-port <port> p2p server tcp port
--p2p-udp-port <port> p2p server udp port
--p2p-nat <ip> p2p server nat ip
--max-peers <peers> max p2p peers count
--max-dials <dials> max p2p dials count
--bootnodes <bootnodes...> comma separated list of bootnodes
--datadir <path> chain data dir path (default: "~/.rei")
--keystore <keystore> the datadir for keystore (default: "keystore")
--unlock <unlock> comma separated list of accounts to unlock
--password <password> password file to use for non-interactive password input
--chain <chain> chain name: rei-mainnet, rei-testnet, rei-devnet
--mine mine block
--coinbase <address> miner address
--verbosity <verbosity> logging verbosity: silent, error, warn, info, debug, detail (default: "info")
--receipts-cache-size <receiptsCacheSize> receipts cache size
--evm <evm> evm implementation type, "js" or "binding"
-h, --help display help for command
Commands:
account Manage accounts
attach [ipcpath] Start an interactive JavaScript environment (connect to node)
console Start an interactive JavaScript environment
Block producer startup
rei --mine --coinbase 0x...abc --unlock 0x...abc --password ./password
Normal node startup
rei --rpc --rpc-host 0.0.0.0
Bootnode startup
rei --p2p-nat 1.2.3.4
Testnet node startup
rei --chain rei-testnet
This monorepo uses npm workspaces. It links the local packages together, making development a lot easier.
Install:
npm install
Build:
npm run build -ws
Windows users might run into the following error when trying to install the repo: '.' is not recognized as an internal or external command
. To remediate for this, you can force Windows to use Git bash to run scripts (you'll need to install Git for Windows for this) with the following command:
npm config set script-shell "C:\\Program Files (x86)\\git\\bin\\bash.exe"
If you ever need to reset this change, you can do so with this command:
npm config delete script-shell
Adds dependencies listed in the root package.
Builds all monorepo packages.
To build a specific package, use npm run build -w @rei-network/contracts
Only build single monorepo package.
Removes root and packages node_modules
, dist
directories, and other generated files.
Only remove dist
directories for each monorepo packages.
These scripts execute lint and lint:fix respectively, to all monorepo packages.
-
Q: Why do I get
EACCES: permission denied
ornode-gyp: Permission denied
when I install@rei-network/cli
?like this
> [email protected] install /xxx/v14.16.1/lib/node_modules/@rei-network/cli/node_modules/bigint-buffer > npm run rebuild || echo "Couldn't build bindings. Non-native version used." Error: EACCES: permission denied, scandir '/xxx/v14.16.1/lib/node_modules/@rei-network/cli/node_modules/bigint-buffer' > [email protected] install /xxx/v14.16.1/lib/node_modules/@rei-network/cli/node_modules/bcrypto > node-gyp rebuild sh: 1: node-gyp: Permission denied npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file sh npm ERR! errno ENOENT npm ERR! [email protected] install: `node-gyp rebuild` npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /xxx/.npm/_logs/2021-07-14T02_24_45_172Z-debug.log
A: Please run
npm install @rei-network/cli -g --unsafe-perm=true --allow-root
-
Q: Why do I get
SyntaxError: Unexpected token '?'
when I runrei
?like this
/xxx/v12.20.0/lib/node_modules/@rei-network/cli/node_modules/@gxchain2/discv5/lib/service/addrVotes.js:44 let best = [tiebreakerStr, this.tallies[tiebreakerStr] ?? 0]; ^ SyntaxError: Unexpected token '?' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.<anonymous> (/xxx/v12.20.0/lib/node_modules/@rei-network/cli/node_modules/@gxchain2/discv5/lib/service/service.js:18:21) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
A: Please update the node version to 14.0.0 or higher. nvm may be able to help you
-
Q: Why do I get
CMake executable is not found
when I install@rei-network/cli
?like this
npm ERR! code 1 npm ERR! path /root/.nvm/versions/node/v14.16.1/lib/node_modules/@rei-network/cli/node_modules/@rei-network/binding npm ERR! command failed npm ERR! command sh -c npm run install:leveldb && npm run install:napi-macros && npm run install:snappy && npm run build npm ERR! > @rei-network/[email protected] install:leveldb npm ERR! > test -d leveldb || git clone https://github.com/REI-Network/leveldb npm ERR! npm ERR! npm ERR! > @rei-network/[email protected] install:napi-macros npm ERR! > test -d napi-macros || git clone https://github.com/hyperdivision/napi-macros npm ERR! npm ERR! npm ERR! > @rei-network/[email protected] install:snappy npm ERR! > test -d snappy || git clone https://github.com/google/snappy npm ERR! npm ERR! npm ERR! > @rei-network/[email protected] build npm ERR! > cmake-js --CDLEVELDB_BUILD_TESTS=OFF --CDLEVELDB_BUILD_BENCHMARKS=OFF --CDLEVELDB_INSTALL=OFF --CDSNAPPY_BUILD_TESTS=OFF --CDSNAPPY_BUILD_BENCHMARKS=OFF --CDSNAPPY_INSTALL=OFF build npm ERR! npm ERR! [ npm ERR! '/root/.nvm/versions/node/v14.16.1/bin/node', npm ERR! '/root/.nvm/versions/node/v14.16.1/lib/node_modules/@rei-network/cli/node_modules/.bin/cmake-js', npm ERR! '--CDLEVELDB_BUILD_TESTS=OFF', npm ERR! '--CDLEVELDB_BUILD_BENCHMARKS=OFF', npm ERR! '--CDLEVELDB_INSTALL=OFF', npm ERR! '--CDSNAPPY_BUILD_TESTS=OFF', npm ERR! '--CDSNAPPY_BUILD_BENCHMARKS=OFF', npm ERR! '--CDSNAPPY_INSTALL=OFF', npm ERR! 'build' npm ERR! ] npm ERR! clone 'leveldb'... npm ERR! clone 'napi-macros'... npm ERR! clone 'snappy'... npm ERR! info TOOL Using Unix Makefiles generator. npm ERR! info DIST Downloading distribution files to: /root/.cmake-js/node-x64/v14.16.1 npm ERR! http DIST - https://nodejs.org/dist/v14.16.1/SHASUMS256.txt npm ERR! http DIST - https://nodejs.org/dist/v14.16.1/node-v14.16.1-headers.tar.gz npm ERR! ERR! OMG CMake executable is not found. Please use your system's package manager to install it, or you can get installers from there: http://cmake.org. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2022-06-24T06_05_09_742Z-debug.log
A: Please use your system's package manager to install cmake, like
sudo apt install cmake
orsudo yum install cmake