Operator >= not compatible with types tuple() and uint256

Hello !
I’m trying to return the balance of msg.sender from an external contract, but when I try to compare pair.balanceOf() to an uint256, it tells me they are not comparable.

I’m using Solidity 0.8.0 on Remix with OpenZeppelin contracts.

interface TokenInterface {
    function balanceOf(address account) view external;
}

contract Contract {
    address public tokenAddress = 0xc5d63121bA479BAeb666a896e84283a1a0AefAe6;

    TokenInterface token = TokenInterface(tokenAddress);

    function stake(uint256 amount) public {
        require(token.balanceOf(msg.sender) >= amount, "Insufficient balance.");
    
        ...

    }
}

The other contract is an ERC20 built with OpenZeppelin.

Thanks and have a nice day :slight_smile:

1 Like

Hi @Aymane,

Your function doesn’t return uint256

function balanceOf(address account) view external;

Instead of your own interface for ERC20 you could use https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#IERC20

This is what I did, no ?

The function balanceOf is already defined by OpenZeppelin, I just import it and then use it ?

1 Like

Oh I understand, I didn’t specified the returned value (uint256) in my interface.

Thanks !

1 Like

Hi @Aymane,

I have marked my reply as the solution. Glad that makes sense now.