Error: Need to check the asset balance of SmartContract

For AssetHolding - to get token balance of a particular asset in my smartcontract, this is what I’m trying:

Global.current_application_address() = Current Contract Address

Assert(AssetHolding.balance(Global.current_application_address(), _token).hasValue() == Int(1)),, _token).value()),

But it gives me this error:

(Attached screenshot)

That error message isn’t great but it usually means that when you try to compile the program, the compiler cant figure out which subroutine to assign scratch slots to.

This often happens when you try to use a MaybeValue directly as you have here with AssetHolding.balance.

Try something like:

holding := AssetHolding.balance(Global.current_application_address(), _token),