setnode
Note: Before setting up a node, make sure you have installed DMC locally【Install Operating Enviroment】
Start a local DMC node so that you can develop specific functionalities of DMC locally. In the actual development environment, you will need different plugins to run a DMC node.
Create a new folder named start_dmc
and save the code in start_dmc/node.js
:
1 | const dmc = require("chain"); |
Configure HTTP Service
http plugin
For example, http-server-address
is used to configure the local service address, with the default value being 127.0.0.1:8888.
1 | dmc.load('http', { |
For specific HTTP configuration information http plugin
Configure Chain Information
chain plugin
For example, delete-all-blocks
is used to determine whether to delete all state data and block data, with the default value being false.
1 | dmc.load('chain',{ |
For specific Chain configuration information, please refer to the chain plugin
Get P2P Information
net plugin
p2p-listen-endpoint
is used to listen to the address and port for P2P connections, with the default value being 0.0.0.0:9876.
1 | dmc.load('net',{ |
For specific Net configuration information, please refer to the net plugin
Control Block Production Information
producer plugin
producer-name:Control Block Production Information
enable-stale-production:enables block production even if the blockchain is frozen.
1 | dmc.load('producer', { |
For specific Producer configuration information, please refer to the producer plugin
Modify and View DMC Configuration and Data Directories
dmc.data_dir:the directory where DMC data is stored.
dmc.config_dir:the directory where DMC configuration is stored.
1 | dmc.config_dir = 'dmc_config_dir/'; |
Start the Node
1 | dmc.start(); |
Advanced Configuration
Modify DMC listening port and address
Enable HTTP service to listen on port 8889 for all addresses.
Enable P2P service to listen on port 9877 for all addresses.
1 | dmc.load('http', { |
- Modify and view DMC configuration and data directories
1 | // Modify DMC configuration and data directories |
- Set DMC service to reset environment data on startup
1 | dmc.load('chain', { |
Node Code Instance
Save the following code in start_dmc/genesis.json
1 | { |
Save the following code as start_dmc/node.js
to start a local DMC node.
1 | const dmc = require("chain"); |
Note: If you encounter any issues during development and testing, try restarting the DMC node service!
Run DMC development environment:
1 | $ dmc start_dmc/node.js |
Log output (partial)
1 | $ dmc start_dmc/node.js |
If you see the above messages, it indicates that the operation was successful and dmc
has started block production.
Next Chapter:
👉 【write ABI Files】