1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ethereumのプライベートネットワークで送金する体験

Last updated at Posted at 2017-03-09

はじめに

Ethereumのプライベートネットワーク上で、二つのアカウント間でEtherを送金するチュートリアルを体験します。

前提

Geth 1.5.9-stable-a07539fbがインストールされています。

マイニング

マイニングしたEtherが入るアカウントEtherbaseにeth.accounts[0]を指定し、マイニングします。1回で4Etherくらいをマイニングできます。

> miner.setEtherbase(eth.accounts[0])
> miner.start()

accounts[0]と"s"がつきますので、ご注意ください。

Mined block云々というメッセージが表示されたら、マイニングの完了です。マイニング処理を止めます。

> miner.stop()

これで、4Ether以上が[0]に入りました。

> personal.getBalance(eth.accounts[0])
> personal.getBalance(eth.accounts[1])

で各アカウントの金額をwei単位で確認できます。

送金

では、eth.accounts[0]から[1]に3etherを送金したいと思います。
まず、送金前にアカウントをアンロックします。(exitしたり、ターミナルを閉じるとアンロックをやり直す必要があります。)

> personal.unlockAccount(eth.accounts[0])

とすると、パスワードを聞かれますので、作成したときの値を入力します。
unLockではなく、unlockです。Accountsではなく、Accountです。

次に、送金のトランザクションを実行します。

> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(3, "ether")})

これでブロックチェーン上に送金トランザクションが登載されました。しかし、マイニングが完了しないと送金手続きが完了されません。

最後にマイニングをします。

> miner.start()
> miner.stop()
> personal.getBalance(eth.accounts[0])
> personal.getBalance(eth.accounts[1])

こうすると、残高が変動していることがわかります。[0]が元よりも増えているのは、送金した分減額されているのですが、その後にマイニングをして増額しているためです。

感想

比喩的にはマイニングはGitのコミットのようなものだと思いました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?