1

i'm trying to identify when the addLiquidityEth function is called on etherscan. To do this i'm trying to get the MethodID (0xf305d719) from this etherscan transaction: https://etherscan.io/tx/0x905bf752c08e32401a497ef6133633012a30da84bd1b28763e1e150e463105c0

Is there a way to return this through either the etherscan API or using something like Web3.py? I've been playing around with the API for the past hour or so now and can't figure out how to get the value I want.

If anyone has any ideas please lmk, I looked around here and on reddit to no avail unfortunately.

2
  • because adding liquidity will generate an event of increased liquidity you can catch it via emission of the event. But if it wouldn't emit an event, you would have to enable tracing and trace all calls to a particular Uniswap v2 pool with this method signature. I don't think Etherscan is exposing internal transaction api (or maybe as paid service)
    – Nulik
    Commented Dec 14, 2022 at 0:49
  • You can do that by reading the first bytes of the transaction's input field.
    – Ismael
    Commented Dec 15, 2022 at 2:53

1 Answer 1

1
import requests

# Replace YOUR_API_KEY with your Etherscan API key
api_key = "YOUR_API_KEY"

# Specify the contract address and event name
contract_address = "0x0000000000000000"
event_name = "addLiquidityEth"

# Send the request to the getLogs endpoint
response = requests.get(f"https://api.etherscan.io/api?module=logs&action=getLogs&apikey={api_key}&address={contract_address}&topic0={event_name}")

# Print the response
print(response.json())
0

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.