3

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 }
  • 1
    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 Jul 28 '17 at 9:44
  • 1
    I thought so too, but web3.eth.getTransactionReceipt() is not much more helpful either (see above). – Steve Jul 28 '17 at 9:52
2

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.

  • 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 Jul 28 '17 at 11:43
  • 1
    Understood - I've updated the answer with another suggestion. – benjaminion Jul 28 '17 at 12:03
  • 1
    Very cool. Starting geth like so geth console --rpcapi eth,web3,admin and using debug.traceTransaction(txHash) works. – Steve Jul 30 '17 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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