前回はこちら。テストネットワークで、Ethereumを使ってみる
ユーザーを作成する
geth_console
personal.newAccount("user1")
shell-session
"0x3b1a887c19bd3e39e926121db232f9376f2aebed"
geth_console
personal.newAccount("user2")
shell-session
"0xe2a98f7bfc8c08fffc8fdfbabc74e80a9ccb0c6f"
geth_console
personal.newAccount("user3")
shell-session
"0xa7732a8a03be095a4c51dd1174e1dc531b67751b"
EtherBaseをuser1に変更
geth_console
miner.setEtherbase("0x3b1a887c19bd3e39e926121db232f9376f2aebed")
check
geth_console
eth.coinbase
shell-session
"0x3b1a887c19bd3e39e926121db232f9376f2aebed"
マイニング
geth_console
miner.start(1)
マイニング停止
geth_console
miner.stop(1)
user1の残高を確認
geth_console
web3.fromWei(eth.getBalance("0x3b1a887c19bd3e39e926121db232f9376f2aebed"), "ether")
この値は、マイニングをしている時間による
shell-session
35
EtherBaseをuser3に変更。user3がマイニングをするということ。
geth_console
miner.setEtherbase("0xa7732a8a03be095a4c51dd1174e1dc531b67751b")
check
geth_console
eth.coinbase
shell-session
"0xa7732a8a03be095a4c51dd1174e1dc531b67751b"
user1からuser2に送金してみる
ロック解除
geth_console
personal.unlockAccount("0x3b1a887c19bd3e39e926121db232f9376f2aebed")
送金
geth_console
eth.sendTransaction({from: "0x3b1a887c19bd3e39e926121db232f9376f2aebed", to: "0xe2a98f7bfc8c08fffc8fdfbabc74e80a9ccb0c6f", value: web3. toWei(10, "ether")})
pending transactionをチェック
geth_console
eth.pendingTransactions
[{
blockHash: null,
blockNumber: null,
from: "0x3b1a887c19bd3e39e926121db232f9376f2aebed",
gas: 90000,
gasPrice: 20000000000,
hash: "0x43f44eee8875d8ece62a5c9cc1e98a79ce7081b6e618e7d732dc7d879fb0d768",
input: "0x",
nonce: 0,
r: "0xc489c97a13a39d8d3e95ad021990451f753460b731cf8bc7e9bbd115e8a82728",
s: "0x66e66cb65f4dc7cbcde5663e5dabc80390ee25e58311e973186da7aa3a6df0e4",
to: "0xe2a98f7bfc8c08fffc8fdfbabc74e80a9ccb0c6f",
transactionIndex: null,
v: "0x1b",
value: 10000000000000000000
}]
マイニング
geth_console
miner.start(1)
ペンディングが空であることを確認
geth_console
eth.pendingTransactions
[]
マイニング停止
geth_console
miner.stop()
user1の残高を確認
geth_console
web3.fromWei(eth.getBalance("0x3b1a887c19bd3e39e926121db232f9376f2aebed"), "ether")
10.00042が減っている。
24.99958
user2の残高を確認
geth_console
web3.fromWei(eth.getBalance("0xe2a98f7bfc8c08fffc8fdfbabc74e80a9ccb0c6f"), "ether")
10が増えている。
10
user3の残高を確認
geth_console
web3.fromWei(eth.getBalance("0xa7732a8a03be095a4c51dd1174e1dc531b67751b"), "ether")
20.00042
user1; - (10 + 0.00042)
user2; +10
user3; +20 + 0.00042
user3の20はマイニング報酬です。(5 ether/block)
0.00042は、トランザクションの手数料になります。