Hello
I am trying to implement lock functionality. so I have created new app id but getting error.
If I use old app id it 's working fine.
My steps are below
The error says that txna Assets 0 failed, because invalid Assets index 0.
This is most likely because you did not provide the asset ID as foreign asset (aka in asset array) in the transaction app call.
See argument foreignAssets in makeApplicationNoOpTxn.
See documentation Smart contract details - Algorand Developer Portal
I also strongly recommend using the *FromObject version of the SDK calls, namely makeApplicationNoOpTxnFromObject which is much more readable.
PS: I’ve put your code in triple backquotes ``` so it looks better.
Since this recommend back and forth, I would recommend using Discord instead.
Also, it would be great if you could provide the smart contract to help debugging and get feedback.
From what I can see, your smart contract is not using the new ABI, which would actually make the above much simpler. ABI indeed automatically set up the right transaction group and the right foreign assets/app/accounts.
Now for your concrete questions, it looks like you’re trying to access transaction number 2 in the group (gtxn 2), which means you are missing at least one transaction in the group as transaction numbers start at 0.