1
4

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プライベートネットワークのアカウント作成まで

Posted at

はじめに

EthereumのクライアントGethを使って開発を行うときに必要となるアカウント作成までの手順を備忘のためにメモします。

Geth 1.5.9-stable-a07539fbがインストールされたことを前提にし、プライベートネットワーク(以下、PN)で立ち上げる場合について書きます。

genesis.jsonファイルを作成

まず、PN関連のデータを入れておくディレクトリsample_eth_pn(一例)を作成します。

$ mkdir ${HOME}/sample_eth_pn

genesis.jsonファイルを次(一例)のように記述し、上のディレクトリの中に配置します。

{
    "nonce": "0x0000000000000042",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "difficulty": "0x200",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "gasLimit": "0xffffffff"
}

genesisブロックを作成

次のコマンドを実行して、上のgenesisファイルを用い、ブロックチェーンの先頭となるgenesisブロックを生成します。

--datadirオプションをつけているのは、データベースとキーストアのファイルを保存するディレクトリへのパスを指定するためです。

$ geth --datadir ${HOME}/sample_eth_pn init ${HOME}/sample_eth_pn/genesis.json

この処理が完了すると、ブロックチェーンが初期化された状態になります。

Gethを起動

次のコマンドにより、Gethをプライベートネットワークで立ち上げます。

$ geth --datadir ${HOME}/sample_eth_pn console

アカウントを作成

コンソールが起動しているので、> に続けて、次のコマンドを実行します。

> personal.newAccount()

次に、Passphrase:を聞かれますので、そのアカウントのパスワードとなる任意の文字列を入力します。続けて、Repeat passphrase: に同じ値を入力します。

New wallet appeared:(省略)のメッセージの下に、新しく作成したアカウント(16進数20文字の文字列)が緑色で表示されます。
例: "0x39465c7186ac60a930329cb8c5c3fbce9bc0a25c"

アカウントを確認

正常に作成できたことを確認するには、次のコマンドを実行します。

> eth.accounts

すると、["0x39465c7186ac60a930329cb8c5c3fbce9bc0a25c"]というアカウントリストのメッセージが返ってくるはずです。現状、一つのアカウントを作成しているので、一つだけですが、複数のアカウントを作成すると、このリストの中にアカウントが増えていきます。

Gethの終了

次のコマンドでGethを終了します。

> exit

参考リンク

Ethereum(geth)でプライベート・ネットワークを作る手順
ブロックチェーンEthereum入門 2
Ethereum Geth コンソールコマンド一覧
Command Line Options

1
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?