# Modify another address local data in foreign contract occur Invalid Account error

**URL:** <https://forum.algorand.co/t/modify-another-address-local-data-in-foreign-contract-occur-invalid-account-error/6634>\
**Category:** General\
**Tags:** docs, teal, smart-contracts\
**Created:** [May 1, 2022, 8:31am UTC](https://forum.algorand.co/t/modify-another-address-local-data-in-foreign-contract-occur-invalid-account-error/6634 "2022-05-01T08:31:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lishubin](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lishubin](https://forum.algorand.co/u/lishubin)\
**Post date:** [May 1, 2022, 8:31am UTC](https://forum.algorand.co/t/modify-another-address-local-data-in-foreign-contract-occur-invalid-account-error/6634/1 "2022-05-01T08:31:58Z")

</div>

I want to use a smart contract (called A SC) to call b smart contract (called B SC) setter method.  
B SC setter method accept a address, like:

```python
@Subroutine(TealType.none)
    def set_worth(current_address: Expr, new_worth):
        return Seq(
            App.localPut(current_address, local_worth, new_worth),
        )

```

A SC use

```python
InnerTxnBuilder.SetFields({
                TxnField.type_enum: TxnType.ApplicationCall,
                TxnField.application_id: App.globalGet(global_core_contract_id),
                TxnField.on_completion: OnComplete.NoOp,
                TxnField.application_args: [Bytes("set_worth"),
                                            Txn.sender(),
                                            Itob(current_worth.value() + div_ceil(current_worth.value(), Int(10)))
                                            ],
            }),

```

I trying `goal app call` from one address to set another address local status, but not success.  
exception is:

```auto
logic eval error: logic eval error: invalid Account reference

```

my question is:

1. can i call A SC to set another address local status which is stored in B SC?
2. please give me some advice , If it can’t ,

---

<div class="post-metadata">

**Author:** ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)\
**Post date:** [May 1, 2022, 7:56pm UTC](https://forum.algorand.co/t/modify-another-address-local-data-in-foreign-contract-occur-invalid-account-error/6634/3 "2022-05-01T19:56:09Z")

</div>

> [@lishubin](#):
>
> ```auto
> @Subroutine(TealType.none)
> def set_worth(current_address: Expr, new_worth):
> return Seq(
> App.localPut(current_address, local_worth, new_worth),
> )
> 
> ```

It is possible that you did it correctly, but just wanted to highlight some important point.  
A subroutine cannot be “called” directly: instead you need the code of A SC to parse the application arguments and call the subroutine.  
See [https://developer.algorand.org/docs/get-started/dapps/pyteal/#the-smart-contract](https://developer.algorand.org/docs/get-started/dapps/pyteal/#the-smart-contract)

Note also that using the ABI will become strongly recommended very soon: [ABI details - Algorand Developer Portal](https://developer.algorand.org/docs/get-details/dapps/smart-contracts/ABI)  
That is the first argument should not be `Bytes("set_worth")` but the proper method selector.

> [@lishubin](#):
>
> ```auto
> InnerTxnBuilder.SetFields({
> TxnField.type_enum: TxnType.ApplicationCall,
> TxnField.application_id: App.globalGet(global_core_contract_id),
> TxnField.on_completion: OnComplete.NoOp,
> TxnField.application_args: [Bytes("set_worth"),
> Txn.sender(),
> Itob(current_worth.value() + div_ceil(current_worth.value(), Int(10)))
> ],
> }),
> 
> ```

You need to set the `TxnField.accounts` to properly.  
Note that the top transaction should also set this (foreign) `accounts`.

---

<div class="post-metadata">

**Author:** ![lishubin](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lishubin](https://forum.algorand.co/u/lishubin)\
**Post date:** [May 2, 2022, 1:30am UTC](https://forum.algorand.co/t/modify-another-address-local-data-in-foreign-contract-occur-invalid-account-error/6634/4 "2022-05-02T01:30:44Z")

</div>

> [@fabrice](#):
>
> You need to set the `TxnField.accounts` to properly.

Thank you , I will try it again.
