0

I'm using ethers.js library, I have decoded TX, where I see logs, events, etc.

But is there any way how to check that this transaction contains incoming ETH?

When sending ETH, there is .value attribute, but I didn't find a way how to detect that some contract call caused ETH send.

I can detect token send via transfer event, or I can detect withdraw for WETH->ETH conversion, but I would need some universal way how to get amount of incoming ETH.

Is it possible in any way?

Thanks

4
  • if you don't want to enable traces (because it is going to be dead slow) , you can just dump the value to the log at this line : github.com/ethereum/go-ethereum/blob/… add something like: log.Info("value_is","value",value.String(),"contract_addr",addr.String()) (just at the beginning of the function). You will also have to import "github.com/ethereum/go-ethereum/log" package. Then go build and run this custom geth node. Parse the log to extract all the data
    – Nulik
    Jan 25 at 18:46
  • same for StaticCall() , DelegateCall() and all the call variations
    – Nulik
    Jan 25 at 18:47
  • but this only will tell you that some contract at some depth receives eth, not that it is "incoming". To check increase in balances you must trace the state changes
    – Nulik
    Jan 25 at 18:49
  • Unfortunately it's not my contract. I need to call some contracts from the automation script so the only way is probably the slow traces or depends on side-effect events (for example monitor withdraw from WETH if possible, etc). Jan 25 at 22:02

2 Answers 2

2

You need some RPC node provider, which supports traces, to get so-called "internal transactions". For example - debug_traceTransaction You'll get the internal call tree, and you look there for a CALL to the desired address with value > 0

1
  • Thanks, I found also this solution but as mentioned above, it's a deadly slow. Obviously it would be much faster to write solution based on events if possible. Jan 25 at 22:00
0

I think there's nothing built-in. You should write a custom function for that in your smart contract.

1
  • Unfortunately I need it for contract call from the script, not contract. In case of contract it would be much easier in this case. Jan 25 at 22:00

Your Answer

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

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