go-ethereum javascript console 常用命令

  • 创建账户
presonal.newAccount()

这里写图片描述
“0x393b0054f9fe5ce92c8d16e0b9ea7bde65148404”即为创建的新账户地址


  • 查看余额
eth.getBalance("0x393b0054f9fe5ce92c8d16e0b9ea7bde65148404")

这里写图片描述
初始化账户余额为0.


  • 开始/停止挖矿
miner.start()   //开始挖矿
miner.stop()    //停止挖矿

  • 查看现有账户
eth.accounts

这里写图片描述


  • 转账
personal.newAccount()   //创建账户1
personal.newAccount()   //创建账户2
eth.getBalance(eth.accounts[0])     //查看账户0余额,此时可能是0
eth.getBalance(eth.accounts[1])     //查看账户1余额,此时可能是0
miner.start()   //开始挖矿,挣一些余额
//waiting...
miner.stop()    //挣到钱后停止挖矿
eth.getBalance(eth.accounts[0])     //查看账户0余额,此时应该不是0了
eth.getBalance(eth.accounts[1])     //查看账户1余额,此时应该还是0
personal.unlockAccount(eth.accounts[0],"123456") //param1 is 转出账户,param2 is password
eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:100}) //accounts 0向account 1转账100wei
miner.start()   //开始挖矿,这样交易才会被真正写入区块链
//waiting...
miner.stop()    //停止挖矿
eth.getBalance(eth.accounts[0])     //查看账户0余额
eth.getBalance(eth.accounts[1])     //查看账户1余额

猜你喜欢

转载自blog.csdn.net/weixin_39354676/article/details/80899325
今日推荐