简介:
NULS ChainBox是一个基于NULS2.0区块链底层运行环境构建的一套区块链应用快速开发平台。它可以帮助区块链应用开发者快速构建自己的区块链应用,而无需关心复杂的底层逻辑。它包含一套友好的开发流程,开发工具以及若干的模块开发模板。
NULS2.0底层运行环境基于微服务架构,支持多语言模块接入,开发者还可使用ChainBox提供的各种开发模板无需关心如何与NULS2.0模块通信,只需专注于业务的实现。
github地址:https://github.com/lijunzhou/nuls-engine
1.环境准备:
macOS、centos7+、ubuntu 14+或者其他linux内核的操作系统,服务器最低标准4核8G
安装 Git (推荐yum安装)
安装命令
yum -y install git
git --version
安装Maven
yum -y install wget
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
安装JDK11
我这边使用的我自己的阿里云提供服务
jdk11下载
https://pan.baidu.com/s/1rpS9DZ5PIlKpp3OGSxlodQ
maven和jdk配置在系统参数中
JAVA_HOME=/var/java/jdk11 #这个是jdk解压后mv之后的名称
JRE_HOME=$JAVA_HOME/lib
export JAVA_HOME JRE_HOME
export MAVEN_HOME=/var/local/apache-maven-3.3.9 #这个是maven解压之后的路径
export MAVEN_HOME
export PATH=$PATH:$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH
2.获取NULS ChainBox程序
打开终端,执行以下命令
git clone https://github.com/lijunzhou/nuls-engine.git chainbox
3.构建加密邮件模块
执行命令进入chainbox/example目录
cd chainbox/example #进入示例文件夹
执行命令构建模块
./package #执行构建脚本(模板提供)
看到以下输出后,说明构建完成
============ PACKAGE FINISH ===============
4.集成加密邮件模块
回到chainbox根目录
cd ..
执行命令,集成加密模块到NULS2.0运行环境中
./tools -p example
看到以下输出后,说明集成成功
============ PACKAGE FINISH ===============
完成后在chainbox目录下会生成NULS-WALLET文件夹,此文件夹包含了集成了加密邮件模块的NULS2.0运行程序
5.修改区块链配置
进入NULS-WELLET文件夹,打开.default-config.ncf修改配置文件(如果同目录下有nuls.ncf,请修改nuls.ncf),请修改以下几项:
minNodeAmount=2 改为 0,修改后确保1个节点也能出块。
#最小链接节点数,当链接到的网络节点低于此参数时,会持续等待
minNodeAmount=0
去掉多余的出块种子地址,修改后确保在1个节点运行时也能10秒钟出一个块。
#种子节点出块地址
seedNodes=tNULSeBaMkrt4z9FYEkkR9D6choPVvQr94oYZp
6.启动节点程序
配置完成后,在NULS-WALLET目录执行以下命令
./start-mykernel
看到以下内容说明模块正在启动中
LOG PATH : ~/NULS-WALLET/Logs
DATA PATH : ~/NULS-WALLET/data
CONFIG FILE : ~/NULS-WALLET/nuls.ncf
DEBUG : 0
JAVA_HOME : /Library/java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
====================
NULS-WALLET STARING
====================
可通过以下命令检查模块启动情况
./check-status
看到以下内容表示节点模块已全部启动成功
==================MODULE PROCESS====================
account PROCESS IS START
block PROCESS IS START
consensus PROCESS IS START
ledger PROCESS IS START
network PROCESS IS START
transaction PROCESS IS START
==================RPC REDAY MODULE==================
account RPC READY
block RPC READY
consensus RPC READY
ledger RPC READY
network RPC READY
transaction RPC READY
======================REDAY MODULE==================
account STATE IS READY
block STATE IS READY
consensus STATE IS READY
ledger STATE IS READY
network STATE IS READY
transaction STATE IS READY
================TRY RUNNING MODULE==================
account TRY RUNNING
block TRY RUNNING
consensus TRY RUNNING
ledger TRY RUNNING
network TRY RUNNING
transaction TRY RUNNING
===================RUNNING MODULE===================
account STATE IS RUNNING
block STATE IS RUNNING
consensus STATE IS RUNNING
ledger STATE IS RUNNING
network STATE IS RUNNING
transaction STATE IS RUNNING
==================NULS WALLET STATE=================
==========================
NULS WALLET IS RUNNING
==========================
7.导入种子节点出块地址
现在种子节点已经启动,我们需进入命令行导入默认的种子出块地址,让节点开始出块
首先进入命令行
./cmd
导入出块地址
nuls>>> import b54db432bba7e13a6c4a28f65b925b18e63bcb79143f7b894fa735d5d3d09db5 #通过私钥导入种子节点地址,此私钥生成的地址必须与第5步第2条的地址相同
Please enter the password (password is between 8 and 20 inclusive of numbers and letters), If you do not want to set a password, return directly.
Enter your password:********** #设置导入地址的密码,此密码与第4步第3条记录的密码必须一致
Please confirm new password:********** #重复上一步输入的密码
tNULSeBaMkrt4z9FYEkkR9D6choPVvQr94oYZp #导入地址成功,验证此地址是否与第4步第2条的配置项完全一致
8.使用加密邮件
准备2个账户,用于测试发送和接收邮件,下方两个地址是测试环境创世块中定义的地址,账户中有一定数量的资产供测试使用。
nuls>>> import 477059f40708313626cccd26f276646e4466032cabceccbf571a7c46f954eb75
Please enter the password (password is between 8 and 20 inclusive of numbers and letters), If you do not want to set a password, return directly.
Enter your password:**********
Please confirm new password:**********
tNULSeBaMnrs6JKrCy6TQdzYJZkMZJDng7QAsD
nuls>>> import 8212e7ba23c8b52790c45b0514490356cd819db15d364cbe08659b5888339e78
Please enter the password (password is between 8 and 20 inclusive of numbers and letters), If you do not want to set a password, return directly.
Enter your password:**********
Please confirm new password:**********
tNULSeBaMrbMRiFAUeeAt6swb4xVBNyi81YL24
9.测试
绑定邮箱地址
请求地址:http://127.0.0.1:9999/mail/createMailAddress
请求参数:
{
"address":"tNULSeBaMrbMRiFAUeeAt6swb4xVBNyi81YL24",
"password":"nuls123456",
"mailAddress":"zqy13917449434@163.com"
}
发送邮件
请求地址:http://127.0.0.1:9999/mail/sendMail
请求参数:
{
"senderAddress": "asd@nuls.io",
"password": "nuls123456",
"mailAddress": "zqy13917449434@163.com",
"title": "haha",
"content": "gogo"
}
查看邮件
请求地址:http://127.0.0.1:9999/mail/viewMail
请求参数:
{
"password": "nuls123456",
"address": "tNULSeBaMrbMRiFAUeeAt6swb4xVBNyi81YL24",
"hash": "84708459a981f95999f91809acf99f81001ad268617634de8256ed56385468b0"
}
10.解决启动start-mykernel报错的问题
将上面红色框内的jdk地址改成本地jdk地址(本图片中是已经解决后的)
11.解决启动cmd报错的问题
将上面红色框内的jdk地址改成本地jdk地址(本图片中是已经解决后的)
12.后期会将钱包和区块链浏览器推出来,请关注更新
如果有问题请评论中体现,看到会给大家解决。