1

I am trying to decode some transactions logs and have hit a problem with one of the entries. In the event log for 0x1c50c336329a7ee41f722ce5d848ebd066b72bf44a1eaafcaa92e8c0282049d2 the first three events are a transfer, a deposit, and a transfer. The fourth one (# 488) refers to the UniswapV3Pool contract 0xf4ad61db72f114be877e87d62dc5e7bd52df4d9b, for which I can't retrieve the ABI information. When I try it via the Etherscan API, I get back:

{
    status: "0",
    message: "NOTOK",
    result: "Contract source code not verified"
}

Since the Etherscan.io summary provides sane data in respect of this entry, I assume that Etherscan had some way of getting the ABI information?

I am obviously missing something!

Any help is appreciated.

1 Answers1

2

The four entry has topic 0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67.

Using the Ethereum Signature Database we get it refers to the event

Swap(address,address,int256,int256,uint160,uint128,int24)

Looking at the verified source on Etherscan it is declared as

/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
    address indexed sender,
    address indexed recipient,
    int256 amount0,
    int256 amount1,
    uint160 sqrtPriceX96,
    uint128 liquidity,
    int24 tick
);

To read from 4bytes directory

curl -X GET https://www.4byte.directory/api/v1/event-signatures/?hex_signature=0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67
Ismael
  • 30,570
  • 21
  • 53
  • 96
  • Thanks @Ismael.

    Apologies for being a bit slow with this but I can't seem to get the lookup to work.

    My understanding is that I should be able to get the signature by providing the topic as follows:

    https://www.4byte.directory/api/v1/signatures/?hex_signature=0xc42079f9

    Likewise, I should be able to go the other way and generate the topic as follows:

    https://www.4byte.directory/api/v1/signatures/?text_signature=Swap(address,address,int256,int256,uint160,uint128,int24)

    However, neither works. Can you advise the URL you used to lookup the hex signature?

    – user3115148 Dec 11 '21 at 12:32
  • 1
    @user3115148 I've added the curl command that can be used to retrieve the event signature. Events signatures are 32 bytes in length. – Ismael Dec 11 '21 at 15:55
  • event-signatures, not just “signature” in your url will fix it – DrGorilla.eth Dec 11 '21 at 15:59
  • How did Etherscan figure out about this Swap() function? Do they use Ethereum Signature Database also? – sirjay Feb 24 '24 at 13:52
  • How programmatically get that function under Looking at the verified source on Etherscan it is declared as? – sirjay Feb 24 '24 at 17:10
  • @sirjay Please, create a new question instead of using comments that way it will be more visible. You can add a link to this question if it helps to set the context. – Ismael Feb 24 '24 at 18:37