# TEAL 'foreign apps'

**URL:** https://forum.algorand.co/t/teal-foreign-apps/2820
**Category:** Uncategorized
**Tags:** teal
**Created:** [March 16, 2021, 10:54am UTC](https://forum.algorand.co/t/teal-foreign-apps/2820 "2021-03-16T10:54:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![AlgoPete92](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@AlgoPete92](https://forum.algorand.co/u/AlgoPete92)
#### Post date: [March 16, 2021, 10:54am UTC](https://forum.algorand.co/t/teal-foreign-apps/2820/1 "2021-03-16T10:54:47Z")

</div>

Hi all,  
I have a little question about the PyTeal syntax. What is the purpose of defining an array of foreign apps when deploying the smart contract, if i can’t use it inside the smart contract? In fact, the PyTeal documentation says that you need to explicitly use the app-id of the external app you want to access.

Ex: App.localGetEx(Int(0), Int(42), Bytes(“key”))

where ‘Int(42)’ is the id of the application to read from. Why can’t i just pass the index of the foreignApps array instead? (Like i do for Txn.application\_args array)

---

<div class="post-metadata">

### Author: ![JasonW](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@JasonW](https://forum.algorand.co/u/JasonW)
#### Post date: [March 16, 2021, 12:45pm UTC](https://forum.algorand.co/t/teal-foreign-apps/2820/2 "2021-03-16T12:45:25Z")

</div>

I believe the application array, assets array, and accounts arrays are used as an optimization to load these from the ledger before the code is evaluated. When you load an account you are already getting the assets and apps (local storage) that associated with that account so no need to go to the application array for this specific call for local storage values.

---

<div class="post-metadata">

### Author: ![jasonpaulos](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.algorand.co/jasonpaulos/32/617_2.png) [@jasonpaulos](https://forum.algorand.co/u/jasonpaulos)
#### Post date: [March 19, 2021, 6:40pm UTC](https://forum.algorand.co/t/teal-foreign-apps/2820/3 "2021-03-19T18:40:51Z")

</div>

It’s also worth noting that the upcoming TEAL v3 release (the spec was in [this PR](https://github.com/algorandfoundation/specs/pull/37)) will expose ForeignApps and ForeignAssets to TEAL.
