5

I am getting into a bit of chain analysis and am using web3.eth.getTransaction('0x8ab08c56c46ca42091ec44c7c9148fe5eb6e0355eeffb29acb5f6c3326139f9e') to get the following transaction details:

{ blockHash: '0x2e5521db5cb9ea805cf50d979684969656fc3ecda22db58f16881af9d15da083',
  blockNumber: 48729,
  from: '0x3d0768da09ce77d25e2d998e6a7b6ed4b9116c2d',
  gas: 115510,
  gasPrice: { [String: '55866980572'] s: 1, e: 10, c: [ 55866980572 ] },
  hash: '0x8ab08c56c46ca42091ec44c7c9148fe5eb6e0355eeffb29acb5f6c3326139f9e',
  input: '0x60606040526040516102b43803806102b48339016040526060805160600190602001505b5b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b806001600050908051906020019082805482825590600052602060002090601f01602090048101928215609e579182015b82811115609d5782518260005055916020019190600101906081565b5b50905060c5919060a9565b8082111560c1576000818150600090555060010160a9565b5090565b50505b506101dc806100d86000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b514610044578063cfae32171461005157610042565b005b61004f6004506100ca565b005b61005c60045061015e565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015b57600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f016020809104026020016040519081016040528092919081815260200182805480156101cd57820191906000526020600020905b8154815290600101906020018083116101b057829003601f168201915b505050505090506101d9565b90560000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000',
  nonce: 8,
  to: null,
  transactionIndex: 0,
  value: { [String: '0'] s: 1, e: 0, c: [ 0 ] },
  v: '0x1b',
  r: '0x323e3ddd61c16d168fc73e1935e584b79e114a782fd424697abae985ee5d5906',
  s: '0x7f0b4c986006eebb87342b04e6b147778ca678393d520ced5f336c1ab081bab9' }

Etherscan tells me that this transaction failed. How can I deduce that information from the above data?

UPDATE: Using web3.eth.getTransactionReceipt('0x8ab08c56c46ca42091ec44c7c9148fe5eb6e0355eeffb29acb5f6c3326139f9e') does not yield much more info either:

{ blockHash: '0x2e5521db5cb9ea805cf50d979684969656fc3ecda22db58f16881af9d15da083',
  blockNumber: 48729,
  contractAddress: '0xf914866d52b690553c0aacece3b38cc8b463ea50',
  cumulativeGasUsed: 115510,
  from: '0x3d0768da09ce77d25e2d998e6a7b6ed4b9116c2d',
  gasUsed: 115510,
  logs: [],
  logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
  root: '0xab42de6a98857259b73d8a1081ed068942cbff6e6b673a931ce97df3dc3350ee',
  to: null,
  transactionHash: '0x8ab08c56c46ca42091ec44c7c9148fe5eb6e0355eeffb29acb5f6c3326139f9e',
  transactionIndex: 0 }
4
  • 2
    web3.eth.getTransactionReceipt() should be used to get the transaction status. Not sure how to verify if the transaction failed or successful. Probably block number might be empty in case of failed transaction.
    – Abhishek
    Commented Jul 28, 2017 at 9:44
  • 1
    I thought so too, but web3.eth.getTransactionReceipt() is not much more helpful either (see above).
    – Steve
    Commented Jul 28, 2017 at 9:52
  • @Steve, cool are you 0x3D0768da09CE77d25e2d998E6a7b6eD4b9116c2D? Commented Oct 13, 2021 at 4:52
  • @WilliamEntriken no that address is mine. Interesting to see someone find it. :-) 0x262fed02268804090aebfb4e24c2702620f9a249f69343937404d8f86be79ef4
    – linagee
    Commented Dec 10 at 20:10

2 Answers 2

3

One way is to check if gas sent == gas used. If so, you can be reasonably certain the transaction aborted. Gas sent is in the getTransaction info: 115510; gas used is in the getTransactionReceipt info, also 115510. See this comprehensive write-up.

To access further info I think you'll need to enable transaction tracing on your node and use the node-specific tools to explore the trace logs. See Parity's trace module for example. This is able to return success status of all transactions etc. I think Geth's debug management API can do similar.

3
  • 1
    I am analysing 1000s of transactions and when sending Ether for example the gas sent == gas used (21000) so this would not hold then.
    – Steve
    Commented Jul 28, 2017 at 11:43
  • 1
    Understood - I've updated the answer with another suggestion. Commented Jul 28, 2017 at 12:03
  • 1
    Very cool. Starting geth like so geth console --rpcapi eth,web3,admin and using debug.traceTransaction(txHash) works.
    – Steve
    Commented Jul 30, 2017 at 8:03
0

When using the web3 1.x, the returned result from web3.eth.getTransactionReceipt(hash) hast a status field which if true, the transaction was successful

 {
  blockHash: '0x1ddd1e460746115186874a9c1c1d232fc9f65bc60e4ffc740f36e85f629eb6f5',
  blockNumber: 16038776,
  contractAddress: null,
  cumulativeGasUsed: 10223841,
  effectiveGasPrice: 10608032517,
  from: '0x046b7aa8c3edb1022b9b9e0e59f4bfdb2f328191',
  gasUsed: 48513,
  logs: [
    {
      address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
      blockHash: '0x1ddd1e460746115186874a9c1c1d232fc9f65bc60e4ffc740f36e85f629eb6f5',
      blockNumber: 16038776,
      data: '0x00000000000000000000000000000000000000000000000000000000004c4b40',
      logIndex: 191,
      removed: false,
      topics: [Array],
      transactionHash: '0xcfd490f3e7a5d0916de22b7fd788fda2e72df6b75baa268f8028380c434684f3',
      transactionIndex: 126,
      id: 'log_b092b10b'
    }
  ],
  logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000008100008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000001000000000000000800000000000000010000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000002000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000',
  status: true,
  to: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
  transactionHash: '0xcfd490f3e7a5d0916de22b7fd788fda2e72df6b75baa268f8028380c434684f3',
  transactionIndex: 126,
  type: '0x0'
}

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.