Asch官网文档好像没人维护似得,有好多问题,经本人多次尝试,顺利解决问题,遂记录下来。
默认测试网络,如果想用主网络,需要将asch/config-mainnet.json文件覆盖config.json文件
git clone https://github.com/AschPlatform/asch.git
默认是测试网络
cd asch
npm install
./aschd upgrade
node app.js
此时会发现控制台在产生区块
http://localhost:4096/api/blocks/getHeight 可以查看区块高度
http://localhost:4096 可以开启登录页,登录localnet 的创世区块会有1亿初始XAS,创世账户主密码为:stone elephant caught wrong spend traffic success fetch inside blush virtual element
cd ..
git clone https://github.com/AschPlatform/asch-cli
cd asch-cli
npm install
./asch-cli/bin/asch-cli crypto -g
? Enter number of accounts to generate 5
随后会生成5账户,包含地址和公私钥
mkdir manage-money-matters
cd manage-money-matters
../asch-cli/bin/asch-cli chain -c
Copying template to the current directory ...
? Enter chain name manage-money-matters
? Enter chain description cs
? Enter chain link https://manage-money-matters.zip
? Enter chain icon url https://manage-money-matters.png
? Enter public keys of chain delegates - hex array, use ',' for separator d2d23d27dd530b0461cfcb762307e3fba8545011d1cdc78fc6b9b45fdc53d2d6,9d585f4bad66
c7b56c74826767ca3aa10961ea6c70a66ecc7593d3bebb517552,f98e28f0220edcaca0ae9f62010436bc79ab237346550a103665dada166f30b2,a43dc3d390fb44b882b8178627f0e417c
d92a6c89a3cd63e7735e92871a1cd78,474a8257c06ec5a9df47a40c099fc6f36496f2a2efc912a71466bb92874a1cff
? How many delegates are needed to unlock asset of a chain? 3
Chain meta information is saved to ./chain.json ...
不发行资产的情况:
../asch-cli/bin/asch-cli chain -g
? Enter master secret of your genesis account [hidden]
? Do you want publish a inbuilt asset in this chain? No
New genesis block is created at: ./genesis.json
发行资产的情况
../asch-cli/bin/asch-cli chain -g
? Enter master secret of your genesis account [hidden]
? Do you want publish a inbuilt asset in this chain? Yes
? Enter asset name, for example: BTC, CNY, USD, MYASSET CNY
? Enter asset total amount 100000000
? Enter asset precision 8
New genesis block is created at: ./genesis.json
利用 asch-cli 提供的 registerchain来完成应用到区块链的注册。 要选择一个有 XAS 的账户,这里我们使用创世账户
../asch-cli/bin/asch-cli -H 127.0.0.1 -P 4096 registerchain -e "stone elephant caught wrong spend traffic success fetch inside blush virtual element" -f chain.json
当发布到主链时用如下命令
../asch-cli/bin/asch-cli -H -P -M registerchain -e "" -f chain.json
在正式部署应用之前,我们需要先修改 config.json ,添加之前生成的受托人以及 peers。其中 peers 里的 ip 要改成自己服务器的 IP 地址
{
"secrets": [
"embrace knee throw alter forward brother lift swarm dizzy accident cliff license",
"bonus symptom climb merit critic admit prevent eye decade entry brick question",
"million deputy search good attract employ office glance elegant brand bacon loud",
"garage glide connect ketchup circle dish speak drive device whale carbon unknown",
"tobacco wine monster mom rapid sting car hole amazing aisle arena aisle"
],
"peers":[{"ip":"127.0.0.1","port":4097}]
}
然后执行命令:
cd ..
cp -r manage-money-matters asch/chains/
cd asch
node app.js或./aschd start