0

I create an erc20 contract on my private blockchain. Then I transfer some tokens from one accout to another. Now I can check on the new block and find that transaction like this:

{
  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
}

but this doesn't show any information about the tokens I sent. Using Transfer.watch can get what I want like this:

  { 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] } } }

I cannot check all the transactions through watch, and watch will not be always online. I want to check the transaction like etherscan.io: enter image description here

What's the solution? Thank you!

2
  • Using geth, you mean directly the CLI? Or using something like Web3js? Commented Jan 9, 2018 at 9:29
  • both CLI and Web3js ^-^ Commented Jan 9, 2018 at 9:33

1 Answer 1

2

I solve this problem by reading this

let's start with the hash of the transaction. in geth ,we can use getTransactionReceipt to get detailed information:

    > 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 ] is the hash of the token transaction; logs.topics[ 1 ] is the from address, and logs.topics[ 2 ] is the to address; and logs.data is the amount, you can copy data into console:

 > 0x00000000000000000000000000000000000000000000043c33c1937564800000
2e+22

2e+22 is exactly the value i sent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.