[区块链]3 以太坊 geth 账户创建、密码、解锁

账户操作命令

(1)创建账户

查看此节点下的所有账户:

eth.accounts

(2)查看块高

eth.blockNumber

(3)创建账户

注意:创建账户需要用 pesonal 角色,其中参数为密码:

> personal.newAccount('123456')
"0xf09dca9e10f3f1d0adfe9af7beeeb579c1d1dd37"
> personal.newAccount('abcdef')
"0x64b3085cd5a4c2ce7456b3ded2fa250545de4de1"
> eth.accounts
["0xd7ec36444d13cc079eb116b4f2602cffcdc9adee", "0xf09dca9e10f3f1d0adfe9af7beeeb579c1e7456b3ded2fa250545de4de1"]

 不建议上述,会暴露密码,推荐使用第二种方式

> personal.newAccount()
Passphrase: 
Repeat passphrase: 
"0xf6c677017eb036f984cbf590e5dde030d1fe8df1"

(4)查看账户余额

> eth.getBalance(eth.accounts[0])
1.15792089237316195423570985008687907853269984665640564039457584007913129639927e+77
> eth.accounts[0]
"0xd7ec36444d13cc079eb116b4f2602cffcdc9adee"

  建立账户别名

> user1=eth.accounts[1]
"0xf09dca9e10f3f1d0adfe9af7beeeb579c1d1dd37"
> eth.getBalance(user1)
0

 

 (5)转账

> personal.unlockAccount(user1)
Unlock account 0xf09dca9e10f3f1d0adfe9af7beeeb579c1d1dd37
Passphrase: 
true
> eth.accounts
["0xd7ec36444d13cc079eb116b4f2602cffcdc9adee", "0xf09dca9e10f3f1d0adfe9af7beeeb579c1e7456b3ded2fa250545de4de1"]
> eth.sendTransaction({from:"0xd7ec36444d13cc079eb116b4f2602cffcdc9adee",to:"0xf09dcc1d1dd37",value:web3.toWei(6,"ether")})
"0x68dc8f5db24371bbb3acca13ff15f3561cae4a6d8753f62beab1356380211949"
> eth.getBalance(user1)
6000000000000000000
> eth.getBalance(user0)
1.15792089237316195423570985008687907853269984665640564039451584007913129639927e+77

转账必须解锁账户,默认账户无需解锁。

可以看到转账后 user1账户有了余额。

 

 

你可能感兴趣的:(区块链)