Logic eval error: invalid ApplicationArgs index 2 but I don't have 3 args

Hi sorry, again I, I have this error, calling the application like this:
ApplicationNoOpTxn(address, params, app_id, foreign_assets=[asa_id], app_args=[intToBytes(asa_id),bytes("put","utf-8")]
In the application I have no reference to indexes over the 1 for the application_args. I don’t really know what’s going on. Can anyone help me?

It looks like your application TEAL code is reading index 2, which is not allowed as you only have 3 arguments.

Can you try to dryrun your code using tealdbg (Smart contract debugging - Algorand Developer Portal) or goal clerk dryrun-remote (Make `goal clerk dryrun` directly work with application calls · Issue #1653 · algorand/go-algorand · GitHub)?

1 Like

OK yes the error seems that, but I have no references to index 2… I will try to use the debugger, i see is in go, it exists also a python implementation included with py-algorand-sdk?

The tealdebugger is just a tool you can use to verify a given dry-runned transaction against Smart Contracts’ logic, step by step. It doesn’t matter if the tool has been written in Go, this is just due to the fact that the Algorand’s node is written in Go. You can actually use Python SDK to create and sign the Application Call transactions you want to test against your PyTeal logic.

If your stack is based on Python, my personal advise is:

  1. Run the sandbox in dev mode, since this reduces debugging time
  2. Deploy your PyTeal smart contract on the sandbox and get the AppID
  3. Create a set of ApplicationCall transactions with py-algorand-sdk associated with unit tests using PyTest
  4. If a given unit test ApplicationCall fails, than write the failed unit test transaction to file
  5. $ ./sandbox copyTo unit_test_txn.signed
  6. $ ./sandbox goal clerk dryrun -t unit_test_txn.signed --dryrun-dump -o unit_test.json
  7. $ ./sandbox tealdbg debug --listen -d unit_test.json
1 Like