0

I am using the Etherscan API to get a list of ERC20 transfer events for a contract, that are relevant to my address:

https://api.etherscan.io/api?module=logs&action=getLogs

https://api.etherscan.io/api?module=logs&action=getLogs&fromBlock=1652080864&toBlock=latest&address=0xa4bbe66f151b22b167127c770016b15ff97dd35c&topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&topic2=0x0000000000000000000000004103c267fba03a1df4fe84bc28092d629fa3f422&apikey=<APIKEY>

The response from my API call is as follows:


{
        "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000dc7a1ad13b9c03da793b512766c39cc990a6e3b0", "0x0000000000000000000000004103c267fba03a1df4fe84bc28092d629fa3f422"],
        "data": "0x0000000000000000000000000000000000000000000000000000000008473b70",
        "blockNumber": "0xe0f2a5",
        "timeStamp": "0x6278fc7b",
        "gasPrice": "0xbdc814c53",
        "gasUsed": "0xb41d",
        "logIndex": "0x85",
        "transactionHash": "0x746fa361320fe7365e7001693ee05db243a5d14086c85a105db1e65eed3d7d7e",
        "transactionIndex": "0x2f"
    }

Is it possible to derive the transaction status from this data? I am trying to avoid calling an additional API call as I will be cycling through a lot of transactions

1 Answer 1

0

Reverted transactions don't have logs, so any transaction that has logs, must be a transaction that got mined and didn't revert.

So status must be true for any transaction you receive from getLogs.

Error handling: Assert, Require, Revert and Exceptions

When a transaction fails it reverts its state -

Such an exception undoes all changes made to the state in the current call (and all its sub-calls) and flags an error to the caller.

Since state is reverted, nothing changes including events.

4
  • thanks, so a transaction like this won't have logs? etherscan.io/tx/… May 9 at 18:01
  • Exactly, failed tx = no logs.
    – Kof
    May 9 at 18:02
  • thank you, do you have any docs you can point me to to learn more about that? May 9 at 18:04
  • Added explanations to answer.
    – Kof
    May 9 at 18:11

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.