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
- node >=
16.0.0
- npm >=
7.0.0
- supported system:
- MacOS 12+
- Any Linux with glibc >=
2.28
and glibcxx >=3.4.25
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, rei
--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
--sync <sync> sync mode: full, snap (default: "full")
--snap-trusted-height <trustedHeight> snap sync trusted height.
this value and trustedHash are specified at the same time to take effect.
snap sync will start from the specified block to verify the legitimacy.
e.g. 100
--snap-trusted-hash <trustedHash> snap sync trusted hash.
this value and trustedHeight are specified at the same time to take effect.
snap sync will start from the specified block to verify the legitimacy.
e.g. 0x123...
--snap-min-td <minTD> minimum total difficulty difference for snap sync
--skip-verify-snap whether skip verifing snapshot
--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"
--bls <bls> the datadir for bls (default: "bls")
--bls-password <blsPassword> bls password file to use for non-interactive password input
--bls-file <blsFile> bls file name
-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
bls Manage bls signature key
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
> bigint-buffer@1.1.5 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' > bcrypto@5.4.0 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! bcrypto@5.4.0 install: `node-gyp rebuild` npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the bcrypto@5.4.0 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.16.1 or higher. nvm may be able to help you