LoginSignup
4

More than 5 years have passed since last update.

ethereumをgo言語のクライアント(geth)で試してみる。
仮想環境(vagrant利用)を利用します。

必要なソフトウエェア

  • Vagrant

Vagrantの公式HPよりインストール。

  • VirtualBox

VirtualBoxの公式HPよりインストール。

  • Vagrant Cloudのアカウント登録

Boxのダウンロード

ネットよりgethがセットアップされたBoxイメージをセットアップ

### Vagrant Cloudへログイン
$ vagrant login
### Vagrant Cloudへpushした、Ethereumのイメージで仮想化環境設定ファイル初期化
$ vagrant init takeshi_hirosue/geth
### 仮想環境起動
$ vagrant up --provider virtualbox

仮想環境へ接続して、作業フォルダに移動

ブロックチェーンの設定ファイルが配置されています。

$ vagrant ssh
Welcome to Ubuntu 15.04 (GNU/Linux 3.19.0-15-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Your Ubuntu release is not supported anymore.
For upgrade information, please visit:
http://www.ubuntu.com/releaseendoflife

New release '15.10' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Fri Apr 14 02:20:36 2017 from 10.0.2.2
$ cd ethereum/
$ cat genesis.json
{
  "nonce": "0x0000000000000042",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "difficulty": "0x01",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "Genesis Block",
    "gasLimit": "0xffffffffffff"
}

ブロックチェーン初期化

geth --datadir ./private init ./genesis.json

クライアント起動

geth --datadir ./private --networkid 123456 --nodiscover --maxpeers 0 --rpc --rpcapi eth,net,web3,personal,admin,miner --minerthreads 1 --rpccorsdomain "*" console

初期アカウント作成

コンソールで以下コマンドでアカウントを作成します。
"pass1"はパスフレーズです。

> personal.newAccount("pass1")

コンパイラ設定(Solidify)

Solidityをコンパイラとして設定します。
取得したイメージには以下パスにバイナリファイルが配置されています。

> admin.setSolc("/usr/local/bin/solc")
"solc, the solidity compiler commandline interface\nVersion: 0.4.10+commit.9e8cc01b.Linux.g++\n"
> eth.getCompilers()
["Solidity"]

以上でブロックチェーンの初期設定は終了です。

クライアント起動(二度目以降)

  • トランザクション送信の際のロックの解除(--unlock)
  • マイニングを同時にスタートさせています(--mine)
  • コンソール表示したい際は console を末尾に指定してください。
geth --datadir ./private --networkid 123456 --nodiscover --maxpeers 0 --rpc --rpcapi eth,net,web3,personal,admin,miner --minerthreads 1 --rpccorsdomain "*" --unlock 0 --mine

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
4