How to set one specify account can update Smart Contract?

Hi everyone,

Account A has reached 10 apps, so I can’t use this account to create more apps.
I use the new Account B to create a new app, it’s ok.
But I want to use account C - this is the specified account in my question and I want to use this account to grant permission to update my app (was created by account A and account B)

This is my TEAL code:

#pragma version 2

byte "msig"
txna ApplicationArgs 0
app_global_put

byte "OwnerPercentage_1"
txna ApplicationArgs 1
btoi
app_global_put
byte "OwnerAddress_1"
txna ApplicationArgs 2
app_global_put

txn OnCompletion
int UpdateApplication
==
bnz handle_updateapp

handle_updateapp:
// This is the specified account I want to use to grant permission to update apps on many accounts
addr 2VQO54JD7VXV7QAHPUFYJD4ZLRA3Z7WR6WYBQEREQBI6ZWHSF5VES4FEHQ
txn Sender
==
return

int 1
return

I got the error message when I create the app:

{"message":"TransactionPool.Remember: transaction V6GE5TKVUMUBVK64TIAU3LQZJKKPEEGYYG56YTD5F4SXZUJCFMOQ: transaction rejected by ApprovalProgram"}

I think my error is because I use another account to create an app (different account 2VQO54JD7VXV7QAHPUFYJD4ZLRA3Z7WR6WYBQEREQBI6ZWHSF5VES4FEHQ). But I don’t know how to resolve my problem.

Anyone can help me, please!

You can debug your code to see where it goes wrong:

My guess is that you did not add application args to your update call, and the program crashes at the beginning txna ApplicationArgs 0.

1 Like

Thank for your response.

My guess is that you did not add application args to your update call, and the program crashes at the beginning txna ApplicationArgs 0 .

This is my transaction to create the app and I added application args. If I change this code

handle_updateapp:
// This is the specified account I want to use to grant permission to update apps on many accounts
addr 2VQO54JD7VXV7QAHPUFYJD4ZLRA3Z7WR6WYBQEREQBI6ZWHSF5VES4FEHQ
txn Sender
==
return

to

handle_updateapp:
int 1
return

then the transaction is created successfully.

Besides, I tried to use tealdbg to debug my code but I got the error:

./tealdbg debug myprogram.teal
2021/08/03 11:39:18 Using proto: https://github.com/algorandfoundation/specs/tree/65b4ab3266c52c56a0fa7d591754887d68faad0a
2021/08/03 11:39:18 Run mode: stateful
2021/08/03 11:39:18 Debug error: all 1 program(s) failed in less than a second, invocation error?

and this is my code:

#pragma version 2
byte "msig"
txna ApplicationArgs 0
app_global_put

byte "admin"
txn Sender
app_global_put

byte "OwnerPercentage_1"
txna ApplicationArgs 2
btoi
app_global_put
byte "OwnerAddress_1"
txna ApplicationArgs 3
app_global_put

txn OnCompletion
int UpdateApplication
==
bnz handle_updateapp

handle_updateapp:
addr 2VQO54JD7VXV7QAHPUFYJD4ZLRA3Z7WR6WYBQEREQBI6ZWHSF5VES4FEHQ
txn Sender
==
return

int 1
return

To debug stateful smart contracts, you need to add context: