Logic eval error: txn index 1, len(group) is 1

Ok, so I have this error where it says logic eval error: txn index 1, len(group) is 1. Details: pc=55, opcodes=== && gtxn 1 Amount and I’m not sure what it’s related to. Here are my conditions:

    return Cond(
        [And(Or(Gtxn[0].xfer_asset() == Int(31566704), Gtxn[0].xfer_asset() == Int(312769), Gtxn[0].xfer_asset() == Int(465865291)), Gtxn[0].asset_receiver() == Global.current_application_address(), Gtxn[1].amount() == Global.min_txn_fee(), Gtxn[1].receiver() == Global.current_application_address()), to_nusd()],
        [And(Gtxn[0].xfer_asset() == Int(657835644), Gtxn[0].asset_receiver() == Global.current_application_address(), Gtxn[1].amount() == Global.min_txn_fee(), Gtxn[1].receiver() == Global.current_application_address()), nusd_to()],
        [Txn.sender() == Addr("RABQ4PRRWJDCMHCCCZ24YTLTT44MI4KFZEMRWGFEYESDRBIKD6QFPNNGBQ"), input_ngbp_price()],
        [And(Or(Gtxn[0].xfer_asset() == Int(31566704), Gtxn[0].xfer_asset() == Int(312769), Gtxn[0].xfer_asset() == Int(465865291)), Gtxn[2].application_args[0] == Bytes("To_Ngbp"), Gtxn[0].asset_receiver() == Global.current_application_address(), Gtxn[1].amount() == Global.min_txn_fee(), Gtxn[1].receiver() == Global.current_application_address()), to_ngbp()],
        [Global.current_application_id() == Int(0), Return(Int(1))],
        [Or(Txn.rekey_to() != Global.zero_address(),Txn.on_completion() == OnComplete.CloseOut,Txn.on_completion() == OnComplete.UpdateApplication,Txn.on_completion() == OnComplete.ClearState,Txn.on_completion() == OnComplete.DeleteApplication,Txn.on_completion() == OnComplete.OptIn,Txn.close_remainder_to() != Global.zero_address(),Txn.asset_close_to() != Global.zero_address()), Return(Int(0))]
    )

As the error states, you have a group with one txn, i.e. len(group) is 1.
But you refere to the 0th and the 1st txn with Gtxn[0] and Gtxn[1], i.e. the group should have
2 txns at least.

2 Likes

Thanks for your response.

Here, it says

[Global.current_application_id() == Int(0), Return(Int(1))],

I forgot to put that this is an app create txn, I apologize. Why is it not completing Return(Int(1))?

The issue is that And or Or are not like && / || on Algorand.
All the expressions are evaluated even if the first expression fails (in the case of &&).
In your specific case

        [And(Or(Gtxn[0].xfer_asset() == Int(31566704), Gtxn[0].xfer_asset() == Int(312769), Gtxn[0].xfer_asset() == Int(465865291)), Gtxn[0].asset_receiver() == Global.current_application_address(), Gtxn[1].amount() == Global.min_txn_fee(), Gtxn[1].receiver() == Global.current_application_address()), to_nusd()],

systematically access Gtxn[1] and crashes.

See Noob cannot deploy smart contract - #4 by fabrice

All the conditions are evaluated in order.

Haha, just figured it out right before you replied. Thank you both for your help!