ethereum取引履歴やトランザクション履歴の確認。

ethereum履歴確認にEthereumExplorerをインストールしましたがコマンドでも確認してみます。

使うコマンド

  • eth.getBlock()

ブロックの中身を取得します。

  • eth.getTransactionFromBlock()

ブロックの中に含まれるトランザクション情報を取得。

  • eth.getTransaction()

トランザクションIDがわかっている場合はトランザクションID指定でトランザクション情報を取得します。

コマンドで確認

やってみましょう

> eth.blockNumber
572
> eth.getBlock(572)
{
  difficulty: 131072,
  extraData: "0xd783010400844765746887676f312e352e31856c696e7578",
  gasLimit: 3141592,
  gasUsed: 0,
  hash: "0x6543df1e790977a328aa980c47fecb9100931100608c2b33043d102dad438498",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x421c0774f55fa2171050a37a05d95bcfcf64b39c",
  nonce: "0x5912e21938f30bee",
  number: 572,
  parentHash: "0x8b88e2419f723cec4500afcfa1cf48d58fd8b92cc73703588d43e1048f547dcc",
  receiptRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 537,
  stateRoot: "0x8397c1f0a3495ad6136e2d0401f12b21892a0c0894bfaa834bab0b90a0a9d79f",
  timestamp: 1450701541,
  totalDifficulty: 75815241,
  transactions: [],  //トランザクションが含まれないブロックなのでトランザクションはから
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}
> eth.getBlock(573)
null //ブロックがなければNULL

トランザクション有の場合を見て見ましょう。
ここでは以下のエントリーで送金した23番ブロックのトランザクションを見てみます。
garapon.hatenablog.com

> eth.getBlock(23)
{
  difficulty: 131904,
  extraData: "0xd783010400844765746887676f312e352e31856c696e7578",
  gasLimit: 3141592,
  gasUsed: 21000,
  hash: "0x81899d652f531e60f8e16c3724d9f464b10596b4f4ca0954df5046847e90d7cd",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x11b00fff3570ac74d66192ffc18d3621b0b3dc4e",
  nonce: "0x1e5c6e214606e6f9",
  number: 23,
  parentHash: "0x6d68ed7bab61970318f2fa372ae7a7acaaac4ffddb3ac282388c7f03850660a7",
  receiptRoot: "0xd45089e134ac677b7fd30573a42ebb4ca453356364d986e10ade88494abe9642",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 649,
  stateRoot: "0x2af06f360e4bdcd5b678c976072c2fcfb11ce623658c37722a043a245e11d277",
  timestamp: 1450230084,
  totalDifficulty: 3157312,
  transactions: ["0xf526695b562b1c77b8e6777ed7b1e8429d70e42e79a0698e8001b0aca38fb926"],  //トランザクション有。
  transactionsRoot: "0xe0d2df7c0082595fae858316cc987cb5aa0e13ad7257e972a95b5cdf8699a32e",
  uncles: []
}
> eth.getTransaction("0xf526695b562b1c77b8e6777ed7b1e8429d70e42e79a0698e8001b0aca38fb926")  //トランザクションID指定で
{
  blockHash: "0x81899d652f531e60f8e16c3724d9f464b10596b4f4ca0954df5046847e90d7cd",
  blockNumber: 23,
  from: "0x11b00fff3570ac74d66192ffc18d3621b0b3dc4e",
  gas: 90000,
  gasPrice: 50000000000,
  hash: "0xf526695b562b1c77b8e6777ed7b1e8429d70e42e79a0698e8001b0aca38fb926",
  input: "0x",
  nonce: 0,
  to: "0xcf573ec35da6c35ded1a5416461de11bec0c89c0",
  transactionIndex: 0,
  value: 10000000000000000000
}
> eth.getTransactionFromBlock(23) //ブロック指定で見る
{
  blockHash: "0x81899d652f531e60f8e16c3724d9f464b10596b4f4ca0954df5046847e90d7cd",
  blockNumber: 23,
  from: "0x11b00fff3570ac74d66192ffc18d3621b0b3dc4e",
  gas: 90000,
  gasPrice: 50000000000,
  hash: "0xf526695b562b1c77b8e6777ed7b1e8429d70e42e79a0698e8001b0aca38fb926",
  input: "0x",
  nonce: 0,
  to: "0xcf573ec35da6c35ded1a5416461de11bec0c89c0",
  transactionIndex: 0,
  value: 10000000000000000000
}
>

ちゃんと01から02に10ethおくったのが見れていますね。

ちなみにEthereumExplorerで該当取引を確認すると。。。
f:id:GARAPON:20160105133051p:plain
こんな風に見えます。
見た目は便利ですが、コマンドのほうが慣れれば楽ですね。