2

I want to create a contract so that when eth_call is called, the contract returns EVM error: CallTooDeep

Tried something like this:

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.17;

contract CallTooDeep {
    function test() public {
        address(this).test();
    }
}

But gets an error:

TypeError: Member "test" not found or not visible after argument-dependent lookup in address.
 --> contracts/CallTooDeep.sol:6:9:
  |
6 |         address(this).test();
  |         ^^^^^^^^^^^^^^^^^^


Error HH600: Compilation failed

How I can fix this error?

3 Answers 3

1

You can't just call the function by its name if there is no imported interface providing the function.

try this:

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.17;

contract CallToDeep {
    function test() public {
       CallToDeep(address(this)).test();
    }
}
1

gasLimit: 29,900,000, 453 Internal Transactions https://goerli.etherscan.io/tx/0xa4e15670efd5d966cce73b807292524f11810bfc5cba9cb08c52de6982d68b89

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.17;

contract CallTooDeep {
    function test() public {
       CallTooDeep(address(this)).test();
    }
}
{
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "data": "0xf8a8fd6d",
            "to": "0xc20a1e280ab7786d718eb38b062b9004943d9eee"

        },
        "latest"
    ],
    "id": 2
}
{
    "jsonrpc": "2.0",
    "id": 2,
    "error": {
        "code": -32000,
        "message": "execution reverted"
    }
}

https://goerli.etherscan.io/tx/0x19c6ef37e7490b19f60b851de85d4a4b0fb472a9445502769f537d8e8ebb0a2e

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.17;

contract CallToDeep {
    function test() public {
       CallToDeep.test();
    }
}
{
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "data": "0xf8a8fd6d",
            "to": "0x26538b1453083081c8180f2600261ddc61730846"

        },
        "latest"
    ],
    "id": 2
}
{
    "jsonrpc": "2.0",
    "id": 2,
    "error": {
        "code": -32000,
        "message": "stack limit reached 1024 (1023)"
    }
}
0

You need to define your function test() before it can be called.

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.