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

イーサリアムでスマートコントラクトを実行した場合のトランザクションの見方(覚書)

Last updated at Posted at 2018-02-15

ERC20トークンを転送(transferをcall)した場合のトランザクション

Function: transfer(address _to, uint256 _value) がトークンの転送では実施される。

送受信アドレスとトークン数を表示するサンプル
// Transaction Hash "0xe85c63caa7d8797fa52ee51d5eea6a19c487cde2173d29cbbe06b701f80280ae"
// にトークンを送信したトランザクションがあるとする

web3.eth.getTransaction("0xe85c63caa7d8797fa52ee51d5eea6a19c487cde2173d29cbbe06b701f80280ae", function(e, tx){
  console.log(tx.from);   // トークンの送信元アドレス
  console.log(tx.to);     // ここはトークンの送信先アドレスではなく、コントラクトアドレス
  var input = tx.input;   // ここにスマートコントラクトの実行内容が入っている
  console.log("0x" + input.substring(34,74));          // トークンの送信先アドレス
  console.log(parseInt(input.substring(75,138),16));   // トークン数
});
開始 終了 意味
1 2 16進予約語 (0x)
3 10 function名(web3.sha3("transfer(address,uint256)").substring(0,10) => "0xa9059cbb")
11 74 第一引数、この場合は送付先アドレス(20文字 = 64Byte(40Byte))
75 138 第二引数、この場合はトークン数(256bit = 32Byte)
0
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
0
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?