-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateWorkspace.sh
More file actions
67 lines (53 loc) · 1.63 KB
/
Copy pathcreateWorkspace.sh
File metadata and controls
67 lines (53 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
create_account() {
i=1
while [ $i -le $2 ]
do
address=$(geth account new --datadir $1 --password $passwordPath)
i=$((i+1))
done
}
mineAccounts_Node(){
i=0
while [ $i -le $2 ]
do
setEtherBaseAccountBool=$(geth --exec 'miner.setEtherbase(eth.accounts['"$i"'])' attach ipc:$1)
minerStartBool=$(geth --exec 'miner.start()' attach ipc:$1)
sleep 1
minerStopBool=$(geth --exec 'miner.stop()' attach ipc:$1)
i=$((i+1))
done
}
mkdir workspace && cd "$_"
echo "{
""\"config"\"": {
""\"chainId"\"": 15,
""\"homesteadBlock"\"": 0,
""\"eip155Block"\"": 0,
""\"eip158Block"\"": 0
},
""\"gasLimit"\"": ""\"9000000000000000000"\"",
""\"difficulty"\"": ""\"500"\"",
""\"alloc"\"": { }
}" > genesis.json
echo "qwerty">password.txt
passwordPath=$(pwd)/password.txt
path1=$(pwd)/node1/geth/nodekey
gethIpc1=$(pwd)/node1/geth.ipc
gethIpc2=$(pwd)/node2/geth.ipc
echo $gethIpc1
$(mkdir node1;geth init genesis.json --datadir node1)
$(mkdir node2;geth init genesis.json --datadir node2)
create_account node1 $1
create_account node2 $1
gnome-terminal --title="Node1" -p -- geth console --datadir node1 --networkid 1729| gnome-terminal --title="Node2" -p -- geth console --datadir node2 --networkid 1729 --port 30304
sleep 3
enodeNode1=$(bootnode -nodekey $path1 -writeaddress)
echo $enodeNode1
enodeWithIP=""\"enode://${enodeNode1}@127.0.0.1:30303"\""
echo $enodeWithIP
addPeerBoolValue=$(geth --exec 'admin.addPeer('"$enodeWithIP"')' attach ipc:$gethIpc2)
echo $addPeerBoolValue
# to add ether to accounts call the mineAccounts_Node function
# mineAccounts_Node $gethIpc1 $1
# mineAccounts_Node $gethIpc2 $1