Question about UpdateApplicationTxn

Is there any point in updating the on_create method of a smart contract in an ApplicationUpdateTxn? The way I see it is once the smart contract is created, the on_create method will run and create the app id and application address. If I update the smart contract through an ApplicationUpdateTxn and change the on_create method, then that defeats the purpose of updating an application right? The idea behind ApplicationUpdateTxn is that you can update the Teal code and keep the same app id & the same contract address. If the ApplicationCreateTxn is called, then a new app id and a new application address will show up.

Is my logic correct?

Yes, in general, you can just remove all the on_create method if you update the application.

One reason you may not want to do that is to allow people to copy your smart contract code (creating a new application ID). Indeed, remove the on_create method would prevent creating a new application with the same code.

Remark: The AVM does not really know about methods and methods are just part of the code. So formally, the answer is: yes, you can just remove the part of the code dealing with creation.

1 Like