1

Let's say i'm programmatically making a transaction to a contract. How can I tell (programmatically) that the confirmed transaction has a Bad Jump Destination? Right now, the only way I know of is it go to etherscan.io and look for the red text. But how can i determine this programmatically?

I'm looking at the response data from a eth_getTransactionByHash call and I can't tell the difference between a Bad Jump Destination and one that worked.

Seems like etherscan has an API that may be able to do this. But shouldn't there be a built in way that doesn't involve etherscan? https://etherscan.io/apis#transactions

------Edit------

My current solution is to check if my transaction has at least 1 confirmation. If it has at least 1 confirmation, then I make an API call to etherscan and check it for errors. Etherscan's response tells me that it's either good or bad jump destination or out of gas. It's pretty amazing, but it seems very round about and hacky. I'll review the other posts you guys have mentioned to see if that solution is better.

  • 2
    Possible duplicate of How do I know when I've run out of gas programmatically? – Ismael Aug 24 '17 at 23:42
  • And also this ethereum.stackexchange.com/questions/6007/…. TL;DR The only realiable way to determine if a transaction has failed is using debug.traceTransaction. – Ismael Aug 24 '17 at 23:44
  • Similar issue for sure, i'll read more into these and see if they provide me a solution. For now, the etherscan API is amazing and works. I just feel like it's round about and ghetto. – LampShade Aug 25 '17 at 4:02
  • 1
    @Ismael Thanks. I've implemented that logic and it's working well. I'm making a call to the network to see how much gas was used for that transaction and comparing it to the amount of gas I supplied. – LampShade Sep 7 '17 at 18:56
1

Currently you would use the same technique as How do I know when I've run out of gas programmatically?

After Metropolis, if you're writing a contract you want to debug, you could log an event and use revert. For example:

event BadInputData();
...
// inside a function
if (inputData == 0) {  // inputData should not be zero
  BadInputData();  // log event
  revert;
}

Then programmatically you can look for the events.

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.