Invalid App Reference

I am grouping 2 transactions:

  1. App creation transaction
  2. App (Different) Opt-in transaction

I am trying to store the app id created in the first transaction while opting into a different app. But when I try to access the app id created in the first transaction using “gaid” opcode, I am getting the error as “Invalid App Reference”? I can’t add the app id as a foreignApp while constructing the transaction because the app hasn’t been created yet.
Any idea on how I could fix it?

This is not something you can currently do. In order for the other app to “see” the newly created App, you’d have to pass it in the foreign apps list. Of course you cant do this ahead of time since you don’t know what the App ID will be.

I think the TEAL devs are looking into making something like this possible, where you get to access any newly created assets/apps automatically but I’m not sure if/when it will be available.


1 Like

Thank you, Ben, for the prompt reply.