1. 程式人生 > >web3j 程式碼控制挖礦開始和停止

web3j 程式碼控制挖礦開始和停止

  Geth  geth = Geth .build(new HttpService("http://localhost:8545/"));
  geth.minerStart(1).send();
  System.out.println("挖礦完成");

注意啟動時啟動引數加上miner 否則會報 method not found 錯誤:

geth --datadir "." --nodiscover  --rpc --rpcapi "db,eth,net,web3,personal,miner"  --targetgaslimit 0xffffffff console 2>>geth.log