Via Tokyo

東京経由--行き

go-ethereumをUbuntuにInstallしただけ

Ethereum logo

Ethereum

go-ethereum(geth)

github.com

Install Ethereum

git clone https://github.com/ethereum/go-ethereum.git

goのinstall versionはgo-ethereumに合わせてください。

curl -O https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

gethのbuild

make -C go-ethereum geth

gethのcopy

sudo cp go-ethereum/build/bin/geth /usr/bin/

テストネットワークでの構築

gethの起動

mkdir eth_data
geth --networkid "123" --datadir "eth_data" --dev console

アカウントの生成

personal.newAccount("test01")
"0xb0feb52d25cacb2d0c883f7a4174bfd0761dcf05"
> INFO [05-27|07:55:38] New wallet appeared                      url=keystore:///home/vagrant/eth_da… status=Locked

personal.newAccount("test02")
"0xf65a886616e35e753a90c9f515fc7deb949992e6"
> INFO [05-27|07:55:55] New wallet appeared                      url=keystore:///home/vagrant/eth_da… status=Locked

アカウントの確認

eth.accounts
["0xb0feb52d25cacb2d0c883f7a4174bfd0761dcf05", "0xf65a886616e35e753a90c9f515fc7deb949992e6"]

残高の確認

eth.getBalance(eth.accounts[0])
0

ブロック数の確認

eth.blockNumber
0

送金

マイニングの開始

miner.start()

マイニングの停止

miner.stop()

指定アカウントの残高確認

eth.getBalance(eth.accounts[0])
130000000000000000000

アカウントをunlock

personal.unlockAccount(eth.accounts[0])
Unlock account 0xb0feb52d25cacb2d0c883f7a4174bfd0761dcf05
Passphrase:
true

personal.unlockAccount(eth.accounts[1])
Unlock account 0x911e54e29650fa2c51f3cb0e93fb5f3162345170
Passphrase:
true

トランザクションの発行

eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(5, "ether")})
INFO [05-27|08:17:19] Submitted transaction                    fullhash=0xfb851c6de0605adf0681b1791dcec7447f92cce70be59f5d227ad739b78b7502 recipient=0x911e54e29650fa2c51f3cb0e93fb5f3162345170
"0xfb851c6de0605adf0681b1791dcec7447f92cce70be59f5d227ad739b78b7502"

未確定トランザクションの確認

eth.pendingTransactions
[{
    blockHash: null,
    blockNumber: null,
    from: "0x7aa69ea7ca70370a35b5125c658aa5c6f857e5a5",
    gas: 90000,
    gasPrice: 0,
    hash: "0xfb851c6de0605adf0681b1791dcec7447f92cce70be59f5d227ad739b78b7502",
    input: "0x",
    nonce: 0,
    r: "0x11d4b1023749c9d1be91fb258fcb4e40c2741667d1b12582e289099542770ac3",
    s: "0x5c502c36bdf7d724df3f25d77121e225a9fe06c47f3de23b37e834d5508de793",
    to: "0x911e54e29650fa2c51f3cb0e93fb5f3162345170",
    transactionIndex: 0,
    v: "0xa95",
    value: 5000000000000000000
}]

マイニングの開始

miner.start()

送金の確認

eth.getBalance(eth.accounts[1])
block            number=50 hash=604970…ebf895
INFO [05-27|08:19:33] 🔗 block reached canonical chain          number=45 hash=3fb0ad…fab8ab
INFO [05-27|08:19:33] 🔨 mined potential block                  number=50 hash=604970…ebf895
INFO [05-27|08:19:33] Commit new mining work                   number=51 txs=0 uncles=0 elapsed=143.224µs

5000000000000000000

gethの停止

マイニングの停止

miner.stop()

gethの停止

exit