0

I wanted to test what the SafeERC20 wrapper contract did, whenever it interacts with a banlisted usdst transfer attempt. But i keep getting weird errors. Is this an inheritance issue? What am i doing wrong?

contract StableCoinBans is Test {

    using SafeERC20 for IERC20;

    IERC20 iusdt;

    function setUp() public {
        iusdt = IERC20(usdt);
    }

    function testSendUsdtSafe() public {
        vm.startPrank(usdtWhale);
        iusdt.safeTransfer(address(123), one);
    }

Compilation fails with this message: Error (9582): Member "safeTransfer" not found or not visible after argument-dependent lookup in contract IERC20.

Ive also tried other ways of writing the same function call:

SafeERC20.safeTransfer(IERC20(usdt), address(123), one);
SafeERC20.safeTransfer(iusdt, address(123), one);

Both of these throw this error, saying that the passed parameter is of the wrong type! That type IERC20 cant become type IERC20???

Error (9553): Invalid type for argument in function call. Invalid implicit conversion from contract IERC20 to contract IERC20 requested.

1 Answer 1

1

Whenever you get Invalid implicit conversion from "X" to "X" error means that you are importing "X" type from two different .sol files. In this specific case you'll need to make sure that the IERC20 is imported from a single source file. When you are importing it from two different source files the compiler tries to resolve the type from two different memory regions and you get this error. Refer this post.

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.