4

We have a smart contract deployed on main net and some of the recent transactions have started failing. Any idea how we can start debugging the contract?

Contract address: 0x81EAF1fF62BB8ccaa5314287B14e75E04E21b8F2

Most recent three transactions that have failed 0x7ea699902c6a4be61d0037baaabbb8be5269cb2956c2fe617e88b82304aba615 0x1e29f225021bc9f9c886bdcb1a5a69af98ae5b7821773c40f0ad23a82975c8e5 0xbe4853a7d079ef35e88bdb3c5e2f44ced4263d13ced64563143514400a342b1b

jatinshah
  • 141
  • 3

2 Answers2

1

I know this is an old post, but for anyone finding this, hopefully this can help.

I've been using tenderly because I have trouble reading the geth debug 2 tool on the scan sites and am currently debugging an issue myself.

https://dashboard.tenderly.co/

When my transaction just says 'failed' it gives me a bit clearer details on why unless it has reverted immediately.

I am by no means an expert, but for the first 3 hashes of this question they all basically reverted after the contract was called.

In many cases this usually means that the input parameters are not correct when passing through a contract and/or the contract tried to do some computation and failed immediately.

A very specific example for myself was when I sent bytes to my contract and decoded them incorrectly.

function encodeStuff(
        address myAddress,
        uint256 amount, 
        address someAddress,
        bytes calldata swapData
    ) external  {
    bytes memory data = abi.encode(myAddress, amount, someAddress, swapData);

}

Then in another function when decoding I tried to unpack the swapData bytes with everything:

        (
         address myAddress,
         uint256 amount, 
         address someAddress,
         address someAddress1,
         address someAddress2,
         address someAddress3,
         address someAddress4,
         bytes memory extra_data1,
         address token_address,
         bytes memory extra_data2
    ) = abi.decode(swapdata, 
    ( 
        address
        uint256
        address
        address, 
        address, 
        address,
        address,
        bytes, 
        address, 
        bytes
    ));

Because I did this, the transaction reverted immediately when it saw there was no extra data to decode from bytes memory data.

I actually needed to decode twice.

// First decode data to get swapData bytes
(address myAddress, uint256 amount, address someAddress, bytes memory swapData) = abi.decode(data, (address, uint256, address, bytes));

// Now decode swapData ( address someAddress1, address someAddress2, address someAddress3, address someAddress4, bytes memory extra_data1, address token_address, bytes memory extra_data2

    ) = abi.decode(swapdata, 
    (
        address, 
        address, 
        address,
        address,
        bytes, 
        address, 
        bytes
    ));

This problem is very specific but the error would show up on scan sites and tenderly just like the hashes in this question, 'Failed' with not much extra data.

If I ever learn more in depth methods of debugging that don't require an arm or leg, I'll update this.

dekubaka
  • 51
  • 1
  • 4
0

Try using seth debug <txhash> with dapptools on a forked mainnet!