Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

以太坊转账,

账户 --> 账户 x 账户 --> 合约 √ 合约 --> 账户 √

1、打开控制台

F:\Geth>geth --datadir "data" console

2、查看目前所拥有的账户列表

eth.accounts

["0xf4fb90bd8713491d62778d0a46f8f6b83b98ed91"]

3、新建账户

personal.newAccount('123456')

"0x1dfa2d1d645e45f5d77025f63b73c8efed9a8240"

4、查看目前所拥有的账户列表

eth.accounts

["0xf4fb90bd8713491d62778d0a46f8f6b83b98ed91", "0x1dfa2d1d645e45f5d77025f63b73c8

efed9a8240"]

5、查看账户余额

eth.getBalance(eth.accounts[0])

665000000000000000000

eth.getBalance(eth.accounts[1])

0

6、定义变量

var acc1=eth.accounts[0]

undefined

acc1

"0xf4fb90bd8713491d62778d0a46f8f6b83b98ed91"

var acc2=eth.accounts[1]

undefined

acc2

"0x1dfa2d1d645e45f5d77025f63b73c8efed9a8240"

7、转账

eth.sendTransaction({from: acc1 , to: acc2, value: web3.toWei(10,"ether")})

Error: authentication needed: password or unlock

    at web3.js:3143:20

    at web3.js:6347:15

    at web3.js:5081:36

    at :1:1

(账户被锁报错)

8、解锁账户

personal.unlockAccount(acc1,"123456")

true

9、转账

eth.sendTransaction({from: acc1 , to: acc2, value: web3.toWei(10,"ether")})

INFO [11-14|14:34:24.526] Setting new local account                address=0xF4f

b90bd8713491d62778D0a46f8F6B83b98Ed91

INFO [11-14|14:34:24.551] Submitted transaction                    fullhash=0x98

f8b9bfb5fbaf374c2d18b5c5691b2cfd1250a1cb76337a47146a2afbde8329 recipient=0x1DfA2

d1d645e45f5d77025f63b73C8eFeD9a8240

"0x98f8b9bfb5fbaf374c2d18b5c5691b2cfd1250a1cb76337a47146a2afbde8329"

10、查看账户余额

eth.getBalance(acc1)

665000000000000000000

eth.getBalance(acc2)

0

11、挖矿

miner.start(1);admin.sleepBlocks(20);miner.stop();

12、挖矿结束查看账户余额

eth.getBalance(acc2)

10000000000000000000

作者:赫灵 链接:https://www.jianshu.com/p/ceb31937ec00 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。