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) |