使用Parity建立ProofofAuthority PoA Ethereum Chain5分钟快速从无到有建立Ethereum联盟链Word格式文档下载.docx
《使用Parity建立ProofofAuthority PoA Ethereum Chain5分钟快速从无到有建立Ethereum联盟链Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《使用Parity建立ProofofAuthority PoA Ethereum Chain5分钟快速从无到有建立Ethereum联盟链Word格式文档下载.docx(5页珍藏版)》请在冰点文库上搜索。
name"
:
"
DemoPoA"
"
engine"
{"
authorityRound"
params"
gasLimitBoundDivisor"
0x400"
stepDuration"
5"
validators"
:
list"
[]}}}},"
maximumExtraDataSize"
0x20"
minGasLimit"
0x1388"
networkID"
0x2323"
},"
genesis"
seal"
step"
0x0"
signature"
0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}},"
difficulty"
0x20000"
gasLimit"
0x5B8D80"
accounts"
0x0000000000000000000000000000000000000001"
balance"
1"
builtin"
ecrecover"
pricing"
linear"
base"
3000,"
word"
0}}}},"
0x0000000000000000000000000000000000000002"
sha256"
60,"
12}}}},"
0x0000000000000000000000000000000000000003"
ripemd160"
600,"
120}}}},"
0x0000000000000000000000000000000000000004"
identity"
15,"
3}}}}}}stepDuration设定成5秒产生一个区块validators设定Authority的地方,目前先空著,后续产生account之后再回来填入将上述资料存成demo-spec.json3.设定两个node此教学会在同一台机器上跑两个node,因此有些Parity原生的设定参数会有衝突,两个node需要分别设定不同值。
-d指定储存资料与帐号的目录--dport指定Parity的networkport,可用来让其他node连接--jsonrpc-port这是JSONRPCport,使用web3.js时会需要ui-portParity提供的Web-basedUIportdapps-portParityDapps使用的port可以用下列指令启动Paritynodeparity--chaindemo-spec.json-d/tmp/parity0--port30300--jsonrpc-port8540--ui-port8180--dapps-port8080--jsonrpc-apisweb3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts除了打一长串的指令外,Parity也提供更为简洁的config档案设定方式,使用--config即可引用设定档。
node0使用如下设定档node0.toml[parity]chain="
demo-spec.json"
base_path="
/tmp/parity0"
[network]port=30300[rpc]port=8540apis=["
web3"
eth"
net"
personal"
parity"
parity_set"
traces"
rpc"
parity_accounts"
][ui]port=8180[dapps]port=8080node1使用如下设定档node1.toml[parity]chain="
/tmp/parity1"
[network]port=30301[rpc]port=8541apis=["
][ui]port=8181[dapps]port=80814.设定帐号(Account)我们总共要开3个帐号:
2个Authority跟1个user帐号。
步骤1、首先启动node0:
parity--confignode0.toml接著开启网页http:
//localhost:
8180我不知道怎么略过WELCOME操作,所以先跟著指示随便建立一个account,然后再删除XD接著新增一个useraccount,使用Recoveraccountfromrecoveryphrase功能,为了示范的一致性,使用user当作passphrase选择第二项输入user完成Useraccount新增Authorityaccount,一样使用Recoveraccountfromrecoveryphrase功能,为了示范的一致性,使用node0当作passphrase选择第二项输入node0最后要看到User与Node0(Authority)account这样就完成node0的帐号设定Authorityaccount:
0x00Bd138aBD70e2F00903268F3Db08f2D25677C9eUseraccount:
0x004ec07d2329997267Ec62b4166639513386F32E步骤2、再来设定node1的帐号,启动parity--confignode1.toml,步骤相同,连接到http:
8181,passphrase使用node1启动Paritynode1输入node1完成Authorityaccount这样就完成node1的帐号设定Authorityaccount:
0x00Aa39d30F0D20FF03a22cCfc30B7EfbFca597C2步骤3、将Authorityaccount写入demo-spec.json档案"
["
0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e"
0x00Aa39d30F0D20FF03a22cCfc30B7EfbFca597C2"
]}再将useraccount加入accounts,并给一些balance,后续可以使用"
0x004ec07d2329997267Ec62b4166639513386F32E"
10000000000000000000000"
}完成后的demo-spec.json如下{"
]}}}},"
3}}}},"
}}}5.启动Authoritynode为了启动Authoritynode来产生区块,我们必须设定负责产生block的signer,分别是node0与node1account步骤1、开启一个node.pwds档案,写入node0与node1的password,内容如下node0node1步骤2、在设定档node0.toml加入[account]及[mining]设定,如下[parity]chain="
][ui]port=8180[dapps]port=8080[account]password=["
node.pwds"
][mining]engine_signer="
reseal_on_txs="
none"
步骤3、node1.toml也一样,如下[parity]chain="
][ui]port=8181[dapps]port=8081[account]password=["
步骤4、分别启动两个nodeparity--confignode0.tomlparity--confignode1.toml6、连接两个node使用Postman透过JSONRPC来测试步骤1、Post下列JSON资料至http:
8540以取得node0的enode资料{"
jsonrpc"
"
2.0"
method"
parity_enode"
[],"
id"
0}取得enode连接资讯步骤2、将node0的enode加入node1,Post下列JSON资料至node1(http:
8541){"
parity_addReservedPeer"
["
enode:
//6c4f53fc8536553c8f151516b7ee17f4b0719d21abe8fdd273588419cf467e3deafb414cd8efa331e4ad55fd7c2820a303a160895129e142a4306e7c3367d67c@172.20.160.80:
30300"
],"
0}你的IP地址会不一样,172.20.160.80成功加入最后到node1的console画面,会看到0/1/25peers,就表示已经连接上。
7.发送transaction通过Parity提供的web-basedUI可以很容易发送transaction,这边就不赘述了。
补充:
分享给区网内其他人使用在开发时通常会将node跑在server上,让其他人可以透过JSONRPCport连接上去使用,此时只要在config里面加入[interface]设定即可。
假设serverip为192.168.1.1,将node0.toml修改如下:
[parity]chain="
]interface="
192.168.1.1"
[ui]port=8180[dapps]port=8080[account]password=["
同样node1.toml修改如下:
[ui]port=8181[dapps]port=8081[account]password=["
本文转自台湾以太坊社区:
00上一篇下一篇