Go-Ethereum

如何使用 GETH 簽出乙太交易中的所有代幣交易?

  • October 26, 2018

我在我的私有區塊鏈上創建了一個 erc20 合約。然後我將一些令牌從一個帳戶轉移到另一個帳戶。現在我可以檢查新塊並找到這樣的交易:

{
 blockHash: "0x860ed4316ecd45b58e439f195a0312111c3e7ef73666d37f382ac2f64b2ce213",
 blockNumber: 3519,
 from: "0xecf6e8cbb8633a3c490d587fa357ad20e21d4b93",
 gas: 90000,
 gasPrice: 0,
 hash: "0xa4aedd34557884e977f0981ab55035527fd990efbee9115d2b37df51ee79180e",
 input: "0xa9059cbb00000000000000000000000089bb2b310f9379986972bc2940461540591a332d00000000000000000000000000000000000000000000043c33c1937564800000",
 nonce: 13,
 r: "0x4b4a8cfb24766e96abfafd2197773e8816683afd7191bb8720e3445ad02ab70c",
 s: "0x69132b6f453aa23f2bd037d0a044b74d5dd1b4b0678af99e8581efc7f66cf8cd",
 to: "0xae4193c5100e173c123619fc2b3845e1091e1aa8",
 transactionIndex: 0,
 v: "0xa96",
 value: 0
}

但這沒有顯示有關我發送的令牌的任何資訊。使用Transfer.watch可以像這樣得到我想要的:

 { address: '0xae4193c5100e173c123619fc2b3845e1091e1aa8',
 blockNumber: 3519,
 transactionHash: '0xa4aedd34557884e977f0981ab55035527fd990efbee9115d2b37df51ee79180e',
 transactionIndex: 0,
 blockHash: '0x860ed4316ecd45b58e439f195a0312111c3e7ef73666d37f382ac2f64b2ce213',
 logIndex: 0,
 removed: false,
 event: 'Transfer',
 args: 
  { from: '0xecf6e8cbb8633a3c490d587fa357ad20e21d4b93',
    to: '0x89bb2b310f9379986972bc2940461540591a332d',
    value: { [String: '2e+22'] s: 1, e: 22, c: [Array] } } }

我無法通過手錶查看所有交易,並且手錶不會始終線上。我想檢查像 etherscan.io 這樣的交易: 在此處輸入圖像描述

解決方案是什麼?謝謝!

我通過閱讀這個來解決這個問題

讓我們從交易的雜湊開始。在 geth 中,我們可以使用getTransactionReceipt獲取詳細資訊:

   > eth.getTransactionReceipt("0x506fea5ae6d5bf08df79b3f2371b553c974a61ba9949225dac9a45017fd0d86d")
{
   blockHash: "0x2a5be303d5326d1004b9bcd840120648f898914f9b8e879b19d072bb19fd9434",
 blockNumber: 3511,
 contractAddress: null,
 cumulativeGasUsed: 53419,
 from: "0xecf6e8cbb8633a3c490d587fa357ad20e21d4b93",
 gasUsed: 53419,
 logs: [{
     address: "0xae4193c5100e173c123619fc2b3845e1091e1aa8",
     blockHash: "0x2a5be303d5326d1004b9bcd840120648f898914f9b8e879b19d072bb19fd9434",
     blockNumber: 3511,
     data: "0x00000000000000000000000000000000000000000000043c33c1937564800000",
     logIndex: 0,
     removed: false,
     topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000ecf6e8cbb8633a3c490d587fa357ad20e21d4b93", "0x00000000000000000000000089bb2b310f9379986972bc2940461540591a332d"],
     transactionHash: "0x506fea5ae6d5bf08df79b3f2371b553c974a61ba9949225dac9a45017fd0d86d",
     transactionIndex: 0
 }],
 logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000008000000000001000000001000000020000000200000000000000000000000000000000000000000000000000000000410000000000000000000100000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000",
 status: "0x1",
 to: "0xae4193c5100e173c123619fc2b3845e1091e1aa8",
 transactionHash: "0x506fea5ae6d5bf08df79b3f2371b553c974a61ba9949225dac9a45017fd0d86d",
 transactionIndex: 0
}

logs.topics[ 0 ]是代幣交易的雜湊值;logs.topics[ 1 ]from地址,logs.topics[ 2 ]to地址;和 logs.data 是數量,您可以將數據複製到控制台:

> 0x00000000000000000000000000000000000000000000043c33c1937564800000
2e+22

2e+22 正是我發送的值。

引用自:https://ethereum.stackexchange.com/questions/35605