Ethereum入門読んでみた④
この記事はEthereum入門読んでみた③の続きです。
前回の記事はこちら ↓
chanichiwasshoi.hateblo.jp
参照しているサイトはこちらです。
etherを送金する - Ethereum入門
etherの送金
// 送金前にアカウントのロックを解除 > personal.unlockAccount(eth.accounts[1]) Unlock account 24afe6c0c64821349bc1bfa73110512b33fa18e1 Passphrase: //パスワードを入力 true > eth.sendTransaction({from: eth.accounts[1], to: eth.accounts[0], value: web3.toWei(5, "ether")}) '0xc86c2a5bdf651f54095eca87e487d4f68f12030dd559f0377e9e7bf1566b9b28' // トランザクション番号
トランザクションの完了にはいずれかのアカウントでマイニングを実行していなければなりません。
マイニングは以下のコードで実行できます。
// マイニングの開始 > miner.start() // マイニング中かどうか確認 > eth.minig true
トランザクション情報を調べる
> eth.getTransaction('0xc86c2a5bdf651f54095eca87e487d4f68f12030dd559f0377e9e7bf1566b9b28') // 先程のトランザクション番号を入力 { blockHash: '0xeef0f74bc51ecb9f3d64099fa4f3c1651af36a632380d41dd987e8e7064a5276', // ブロックのハッシュ値 blockNumber: 11076, // ブロックの番号 from: '0x868d840e872df5134a3be6f7b68e52cb680fe3ac', // 送金元アカウント gas: 90000, // トランザクションの処理時のgas最大値 gasPrice: '55928534329', // 1gasあたりの手数料(wei) hash: '0x5fd0bdcccb379a8b4034668464ad9a499a8a6b7801ed66ac23e4df3d67ec64a5', input: '0x', nonce: 0, to: '0x2efbdc840746c862b63077643e5b7dd8bebb8448', // 送金先アカウント transactionIndex: 0, value: '3000000000000000000' // 総金額(wei) }
まだトランザクションを含んだブロックがマイニングされていないときにはblockHashとblockNumberは空となる。