- Node.js 8.9 or later
- npm 5.6.0 or later
-
Install dependencies
npm install
-
Run smart contract (tendermint ABCI app) server in
smart-contract
repository and wait forCommit Commit
to show in an output before starting
api
process. -
Add development keys to the system (for development mode only)
TENDERMINT_IP=$IP \ TENDERMINT_PORT=$PORT \ npm run initDevKey
-
Run a server
ROLE=$ROLE \ npm start
Environment variable options
ROLE
: Can beidp
,rp
, oras
TENDERMINT_IP
: IP Address to contact tendermint RPC [Default:localhost
]TENDERMINT_PORT
: Port to contact tendermint RPC [Default:45000
for IDP,45001
for RP, and45002
for AS]MQ_CONTACT_IP
: An IP address where this NDID node message queue can be contacted [Required]MQ_BINDING_PORT
: A port to bind message queue [Default:5555
]SERVER_PORT
: API server port [Default:8080
]PRIVATE_KEY_PATH
: Path to private key (if call back to create signature is not set) [Default: using pre-generated development key]MASTER_PRIVATE_KEY_PATH
: Path to master private key (if call back to create signature is not set) [Default: using pre-generated development key]NODE_ID
: Node ID. Only when there are more than one node per role in the system. This ID tie to public key, in dev mode we haverp1
,rp2
,rp3
,idp1
,idp2
,idp3
,as1
,as2
,as3
LOG_DIRECTORY_PATH
: Directory path for log files (only inproduction
environment) [Default:__dirname
(code's directory)]
Examples
-
Run a server as an IDP
ROLE=idp \ MQ_CONTACT_IP=192.168.1.1 \ MQ_BINDING_PORT=5555 \ npm start
-
Run a server as a RP
ROLE=rp \ MQ_CONTACT_IP=192.168.1.1 \ MQ_BINDING_PORT=5555 \ npm start
-
Run a server as a AS
ROLE=as \ MQ_CONTACT_IP=192.168.1.1 \ MQ_BINDING_PORT=5555 \ npm start
Don't forget to
- Set
SERVER_PORT
when running on the same machine to avoid port collision. - Set
TENDERMINT_IP
and/orTENDERMINT_PORT
when runningsmart-contract
/tendermint
on another machine. - Set
NODE_ID
when there are more than one node per role in the system.
Required
- Docker CE Install docker
- docker-compose Install docker-compose
npm run docker-build
npm run docker-up
-
When working in development, if you clear/delete the blockchain, you need to delete DB files and latest block height files by running
npm run reset-data-for-dev
. (Automatically run when runningnpm run initDevKey
) -
Run
npm run delete-local-db-cache
to delete local DB used for caching. Local DB file name isdb-api-
following by node ID (env:NODE_ID
) set on server start (e.g.db-api-idp1
when node ID is set toidp1
). -
Run
npm run delete-latest-block-height
to delete persistent latest block height saved by the server. File name islatest-block-height-
following by node ID (env:NODE_ID
).