2
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.

web3.js で Ethereum のトランザクション詳細を取得

Last updated at Posted at 2018-06-23

web3.js@1.0.0 で Ethereum のトランザクション詳細を取得する方法です。

Ethereum のトランザクション詳細を取得するには、トランザクションの発行時に得ることのできるトランザクションハッシュが必要になります。トランザクションハッシュを引数に、web3.eth.getTransaction を呼ぶことでトランザクションの詳細を取得することができます。

サンプルコード


web3.eth.getTransaction('0x26d07b711961a06eb9f07eefe98895100c647c3972247c40dfc81f4458dd42fa')
.then(console.log);

 上記のコードで取得できた結果

{ blockHash: '0xfb35e7511a7e96b804bca4407241b81d4f0155a48d6967da3c7ff44997e5d868',
blockNumber: 5603794,
from: '0xf2018FA89f4ed6F6109f9A871021adebb3E97035',
gas: 210000,
gasPrice: '41000000000',
hash: '0x26d07b711961a06eb9f07eefe98895100c647c3972247c40dfc81f4458dd42fa',
input: '0xe3818ae7a9bae381aee4b88ae3818be38289e38193e38293e381abe381a1e381afefbc81',
nonce: 0,
r: '0x9bc00cb7500b4efb54835f69cb2534d55ed1099c133ab1aea4f823acfb58a057',
s: '0x167c431e0b7b71ef7e2a82d1beffaf607412589e9b388fbadab254e475d259f8',
to: '0xF02c1c8e6114b1Dbe8937a39260b5b0a374432bB',
transactionIndex: 14,
v: '0x25',
value: '0' }

 * なお、上記で得られた結果は、web3.js の公式ドキュメント上 に記載されている結果と異なります。

  • これはおそらく geth 側の API 変更によるものであると考えれます。
    geth のコード をみると、上記コードでの戻り値と一致しています。
  • Ethereum 関連のプロジェクトはまだまだ開発が盛んに進められている最中で、ドキュメントの更新が間に合っていないようなので、自ら積極的に手を動かしてコードを実行したり、コミュニティに直接貢献していく必要がありそうです。

参考

Note

2
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
2
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?