1、先创建文件夹,以后挖矿就进这目录,名字随意,不一定非要这个
mkdir ChainSkills
cd ChainSkills
mkdir private
2、进入private文件夹
cd private
3、ps:使用puppeth工具
D:\ChainSkills\private>puppeth
+-----------------------------------------------------------+
| Welcome to puppeth, your Ethereum private network manager |
| |
| This tool lets you create a new Ethereum network down to |
| the genesis block, bootnodes, miners and ethstats servers |
| without the hassle that it would normally entail. |
| |
| Puppeth uses SSH to dial in to remote servers, and builds |
| its network components out of Docker containers using the |
| docker-compose toolset. |
+-----------------------------------------------------------+
Please specify a network name to administer (no spaces, hyphens or capital letters please)
> chainskills
Sweet, you can set this via --network=chainskills next time!
[32mINFO [0m[11-22|09:01:22.263] Administering Ethereum network [32mname[0m=chainskills
[33mWARN [0m[11-22|09:01:22.298] No previous configurations found [33mpath[0m=.puppeth\chainskills
What would you like to do? (default = stats)
1. Show network stats
2. Configure new genesis
3. Track new remote server
4. Deploy network components
> 2
What would you like to do? (default = create)
1. Create new genesis from scratch
2. Import already existing genesis
> 1
Which consensus engine to use? (default = clique)
1. Ethash - proof-of-work
2. Clique - proof-of-authority
> 1
Which accounts should be pre-funded? (advisable at least one)
> 0x
Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei? (advisable yes)
>
Specify your chain/network ID if you want an explicit one (default = random)
> 556677
[32mINFO [0m[11-22|09:01:54.950] Configured new genesis block
What would you like to do? (default = stats)
1. Show network stats
2. Manage existing genesis
3. Track new remote server
4. Deploy network components
> 2
1. Modify existing configurations
2. Export genesis configurations
3. Remove genesis configuration
> 2
Which folder to save the genesis specs into? (default = current)
Will create chainskills.json, chainskills-aleth.json, chainskills-harmony.json, chainskills-parity.json
>
[32mINFO [0m[11-22|09:02:10.370] Saved native genesis chain spec [32mpath[0m=chainskills.json
[32mINFO [0m[11-22|09:02:10.372] Saved genesis chain spec [32mclient[0m=aleth [32mpath[0m=chainskills-aleth.json
[32mINFO [0m[11-22|09:02:10.374] Saved genesis chain spec [32mclient[0m=parity [32mpath[0m=chainskills-parity.json
[32mINFO [0m[11-22|09:02:10.376] Saved genesis chain spec [32mclient[0m=harmony [32mpath[0m=chainskills-harmony.json
以上过程会创建这个创世块(genesis block)
5、初始化节点
geth --datadir . init .\chainskills.json
6、创建一个新账户
geth --datadir . account new
会弹出password,输入密码,会是隐形的,会弹出再次确认,得到address,记住这就是账户地址。
7、创建密码文件 password.sec,把你创建账户的密码放在里面。
8、设置主账户(跳过直接做下面一步):
miner.setEtherbase(addr账户地址)
9、对你的账户排序
geth --datadir . account list
10.进入编译器界面输入挖矿命令
粘贴如下命令:
geth --networkid 556677 --cache=2048 --nodiscover --datadir "." --http --http.api "eth,web3,debug,personal,net,miner" --http.corsdomain "*" --http.port=8545 --http.addr="0.0.0.0" --txpool.lifetime 1m --allow-insecure-unlock --unlock 0 --password password.sec console
10、到编译器中打开chainskill文件夹,在private右键创建password.sec,输入第一个账户密码
11、再进入private夹中,开始挖矿(startnode.cmd文件需要自己新建,文件内容就是第10步的挖矿命令)
startnode.cmd
miner.start(1)
12.终止挖矿
miner.stop()
exit 或 ctrl + c
13、可另外打开一个界面,输入命令,另一个挖矿不能停
geth attach ipc:\\.\pipe\geth.ipc
14、在此界面中你可以查有多少账户
eth.accounts
15、查询正在挖矿的账户
eth.coinbase
16、查询账户正在挖矿的账户余额
eth.getBalance(eth.coinbase)
17、查询1账户余额
eth.getBalance(eth.accounts[1])
18、解锁账户
personal.unlockAccount("账户")
19、转账命令(先解锁)
eth.sendTransaction({from:"账户一",to:"账户二",value:web3.toWei(10,"ether")})
20、.换个挖矿账户
miner.setEtherbase("0xffb862171700e1e1954af94d0159a0b0bdd32bd2");
21、终止挖矿
miner.stop
22、开始挖矿
miner.start