スポンサーリンク

WindowsでEthereumスマートコントラクト入門「gethのインストールからHelloWorldまで」を写経してみる(2)

前回の続きです。

http://twosquirrel.mints.ne.jp/?p=21750

(開発環境)
Windows 8.1 Pro 64bit
geth 1.7.3
Visual Studio Code

(0)前回まで何をやったか?

gethのインストール

アカウントの作成(account[0], パスワード: “testPass”)

プライベートネットワーク内でマイニングして、1935 ETHゲットした。

●今回は、accounts[0]から、accounts[1]への送金までをやってみたい。

<gethの入り方>
1.C:/geth/ を、VisualStudioCodeで、「管理者で実行」で開く。
2.Ctrl+@ でターミナルを出して、

geth --networkid 9991357239471 --datadir ./test1 --maxpeers 0 --nodiscover console 2>> node.log

3.終了するときは、exit

image

(1)accounts[1]の作成

personal.newAccount("testPass1")

image

(2)Etherの送金

accounts[0] から、 accounts[1] に、1 ETH = 10^18 wei を送金することとする。

eth.getBalance(eth.accounts[1])

accounts[0]のアンロック

personal.unlockAccount(eth.accounts[0])

image

送金を実行

eth.sendTransaction({ from: eth.accounts[0], to: eth.accounts[1], value: 1000000000000000000 })

image

この断崖ではまだ送金は完了していない。

送金のトランザクションが台帳に記入されるために、マイニングを開始する。

miner.start()
eth.getBalance(eth.accounts[1])

最初、nullとなって焦るが、ちゃんと10^18 weiが送金されたいた。

image

これで、accounts[0]から、accounts[1]まで、ETHの送金がやっとえきるようになった。

次は、Hello Worldを表示するスマートコントラクトを作成したい。

(参考)

https://qiita.com/amachino/items/b59ec8e46863ce2ebd4a
image

スポンサーリンク